Spaces:
Running
Running
Fixed the JSONDecodeError issue.
Browse filesUse ast.literal_eval to parse text into a tuple in remove_image_from_gallery.
- README.md +1 -1
- app.py +3 -2
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 💬
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
---
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.16.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
---
|
app.py
CHANGED
|
@@ -11,6 +11,7 @@ import traceback
|
|
| 11 |
import tempfile
|
| 12 |
import zipfile
|
| 13 |
import re
|
|
|
|
| 14 |
from datetime import datetime
|
| 15 |
from collections import defaultdict
|
| 16 |
from classifyTags import classify_tags
|
|
@@ -483,7 +484,7 @@ def get_selection_from_gallery(gallery: list, tag_results: dict, selected_state:
|
|
| 483 |
if not selected_state:
|
| 484 |
return selected_state
|
| 485 |
|
| 486 |
-
tag_result = { "strings": "", "classified_tags": "", "rating": "", "character_res": "", "general_res": "", "unclassified_tags": "" }
|
| 487 |
if selected_state.value["image"]["path"] in tag_results:
|
| 488 |
tag_result = tag_results[selected_state.value["image"]["path"]]
|
| 489 |
|
|
@@ -515,7 +516,7 @@ def remove_image_from_gallery(gallery: list, selected_image: str):
|
|
| 515 |
if not gallery or not selected_image:
|
| 516 |
return gallery
|
| 517 |
|
| 518 |
-
selected_image =
|
| 519 |
# Remove the selected image from the gallery
|
| 520 |
if selected_image in gallery:
|
| 521 |
gallery.remove(selected_image)
|
|
|
|
| 11 |
import tempfile
|
| 12 |
import zipfile
|
| 13 |
import re
|
| 14 |
+
import ast
|
| 15 |
from datetime import datetime
|
| 16 |
from collections import defaultdict
|
| 17 |
from classifyTags import classify_tags
|
|
|
|
| 484 |
if not selected_state:
|
| 485 |
return selected_state
|
| 486 |
|
| 487 |
+
tag_result = { "strings": "", "classified_tags": "{}", "rating": "", "character_res": "", "general_res": "", "unclassified_tags": "{}" }
|
| 488 |
if selected_state.value["image"]["path"] in tag_results:
|
| 489 |
tag_result = tag_results[selected_state.value["image"]["path"]]
|
| 490 |
|
|
|
|
| 516 |
if not gallery or not selected_image:
|
| 517 |
return gallery
|
| 518 |
|
| 519 |
+
selected_image = ast.literal_eval(selected_image) #Use ast.literal_eval to parse text into a tuple.
|
| 520 |
# Remove the selected image from the gallery
|
| 521 |
if selected_image in gallery:
|
| 522 |
gallery.remove(selected_image)
|
requirements.txt
CHANGED
|
@@ -4,7 +4,7 @@ pillow>=9.0.0
|
|
| 4 |
onnxruntime>=1.12.0
|
| 5 |
huggingface-hub
|
| 6 |
|
| 7 |
-
gradio==5.
|
| 8 |
pandas
|
| 9 |
|
| 10 |
# for reorganize WD Tagger into a readable article by Llama3 model.
|
|
|
|
| 4 |
onnxruntime>=1.12.0
|
| 5 |
huggingface-hub
|
| 6 |
|
| 7 |
+
gradio==5.16.0
|
| 8 |
pandas
|
| 9 |
|
| 10 |
# for reorganize WD Tagger into a readable article by Llama3 model.
|