Update app.py
Browse files
app.py
CHANGED
@@ -526,13 +526,35 @@ def log_information(result_gallery):
|
|
526 |
if result_gallery is not None:
|
527 |
for i, result in enumerate(result_gallery):
|
528 |
print(result[0])
|
529 |
-
|
530 |
def on_select_result(result_slider, result_gallery, evt: gr.SelectData):
|
531 |
print('on_select_result')
|
532 |
if result_gallery is not None:
|
533 |
for i, result in enumerate(result_gallery):
|
534 |
print(result[0])
|
535 |
return [result_slider[0], result_gallery[evt.index][0]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
|
537 |
title_html = """
|
538 |
<h1><center>SUPIR</center></h1>
|
|
|
526 |
if result_gallery is not None:
|
527 |
for i, result in enumerate(result_gallery):
|
528 |
print(result[0])
|
529 |
+
'''
|
530 |
def on_select_result(result_slider, result_gallery, evt: gr.SelectData):
|
531 |
print('on_select_result')
|
532 |
if result_gallery is not None:
|
533 |
for i, result in enumerate(result_gallery):
|
534 |
print(result[0])
|
535 |
return [result_slider[0], result_gallery[evt.index][0]]
|
536 |
+
'''
|
537 |
+
def on_select_result(result_slider, result_gallery, evt: gr.SelectData):
|
538 |
+
print('on_select_result')
|
539 |
+
try:
|
540 |
+
if result_gallery is not None:
|
541 |
+
print(f"Event index: {evt.index}, type: {type(evt.index)}")
|
542 |
+
for i, result in enumerate(result_gallery):
|
543 |
+
print(result[0])
|
544 |
+
# evt.index が整数型か確認し、安全に値を返す
|
545 |
+
if isinstance(evt.index, int):
|
546 |
+
return [result_slider[0], result_gallery[evt.index][0]]
|
547 |
+
else:
|
548 |
+
print("Invalid event index type")
|
549 |
+
return [None, None] # 型が正しくない場合のデフォルト値
|
550 |
+
else:
|
551 |
+
print("result_gallery is None")
|
552 |
+
return [None, None] # result_gallery が空の場合のデフォルト値
|
553 |
+
except Exception as e:
|
554 |
+
print(f"Error in on_select_result: {str(e)}")
|
555 |
+
return [None, None] # その他の例外処理
|
556 |
+
|
557 |
+
|
558 |
|
559 |
title_html = """
|
560 |
<h1><center>SUPIR</center></h1>
|