Commit ·
fb741cc
1
Parent(s): a770416
Fix Gradio compatibility: upgrade to v6.5+ and simplify type annotations
Browse files- .gitignore +3 -0
- app.py +6 -8
- requirements.txt +1 -1
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.venv/
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def setup_yolo():
|
|
| 31 |
return False
|
| 32 |
|
| 33 |
|
| 34 |
-
def predict_yolo(image
|
| 35 |
if not setup_yolo():
|
| 36 |
return None, "YOLO model not available"
|
| 37 |
|
|
@@ -64,7 +64,7 @@ def predict_yolo(image: Image.Image) -> tuple[Corners | None, str]:
|
|
| 64 |
os.unlink(temp_path)
|
| 65 |
|
| 66 |
|
| 67 |
-
def process_single_image(image
|
| 68 |
yolo_corners, yolo_status = predict_yolo(image)
|
| 69 |
|
| 70 |
yolo_viz = None
|
|
@@ -78,7 +78,7 @@ def process_single_image(image: Image.Image) -> tuple[Image.Image | None, str]:
|
|
| 78 |
return yolo_viz, yolo_info
|
| 79 |
|
| 80 |
|
| 81 |
-
def process_images(images
|
| 82 |
results = []
|
| 83 |
|
| 84 |
if images is None:
|
|
@@ -92,7 +92,6 @@ def process_images(images: list) -> list[dict]:
|
|
| 92 |
image = img_data
|
| 93 |
filename = "uploaded_image"
|
| 94 |
else:
|
| 95 |
-
# Handle other cases if necessary, e.g. file objects
|
| 96 |
try:
|
| 97 |
image = Image.open(img_data)
|
| 98 |
filename = "uploaded_image"
|
|
@@ -111,7 +110,7 @@ def process_images(images: list) -> list[dict]:
|
|
| 111 |
return results
|
| 112 |
|
| 113 |
|
| 114 |
-
def create_gallery_output(results
|
| 115 |
yolo_images = []
|
| 116 |
|
| 117 |
for r in results:
|
|
@@ -125,7 +124,7 @@ def create_gallery_output(results: list[dict]) -> tuple:
|
|
| 125 |
return yolo_images, yolo_info
|
| 126 |
|
| 127 |
|
| 128 |
-
def predict(images
|
| 129 |
if images is None or len(images) == 0:
|
| 130 |
return [], "No images uploaded"
|
| 131 |
|
|
@@ -151,8 +150,7 @@ with gr.Blocks(title="Squircle Corners Prediction") as demo:
|
|
| 151 |
input_images = gr.File(
|
| 152 |
label="Upload Images",
|
| 153 |
file_count="multiple",
|
| 154 |
-
file_types=["image"]
|
| 155 |
-
type="filepath"
|
| 156 |
)
|
| 157 |
predict_btn = gr.Button("Predict", variant="primary")
|
| 158 |
|
|
|
|
| 31 |
return False
|
| 32 |
|
| 33 |
|
| 34 |
+
def predict_yolo(image):
|
| 35 |
if not setup_yolo():
|
| 36 |
return None, "YOLO model not available"
|
| 37 |
|
|
|
|
| 64 |
os.unlink(temp_path)
|
| 65 |
|
| 66 |
|
| 67 |
+
def process_single_image(image):
|
| 68 |
yolo_corners, yolo_status = predict_yolo(image)
|
| 69 |
|
| 70 |
yolo_viz = None
|
|
|
|
| 78 |
return yolo_viz, yolo_info
|
| 79 |
|
| 80 |
|
| 81 |
+
def process_images(images):
|
| 82 |
results = []
|
| 83 |
|
| 84 |
if images is None:
|
|
|
|
| 92 |
image = img_data
|
| 93 |
filename = "uploaded_image"
|
| 94 |
else:
|
|
|
|
| 95 |
try:
|
| 96 |
image = Image.open(img_data)
|
| 97 |
filename = "uploaded_image"
|
|
|
|
| 110 |
return results
|
| 111 |
|
| 112 |
|
| 113 |
+
def create_gallery_output(results):
|
| 114 |
yolo_images = []
|
| 115 |
|
| 116 |
for r in results:
|
|
|
|
| 124 |
return yolo_images, yolo_info
|
| 125 |
|
| 126 |
|
| 127 |
+
def predict(images):
|
| 128 |
if images is None or len(images) == 0:
|
| 129 |
return [], "No images uploaded"
|
| 130 |
|
|
|
|
| 150 |
input_images = gr.File(
|
| 151 |
label="Upload Images",
|
| 152 |
file_count="multiple",
|
| 153 |
+
file_types=["image"]
|
|
|
|
| 154 |
)
|
| 155 |
predict_btn = gr.Button("Predict", variant="primary")
|
| 156 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio>=
|
| 2 |
numpy<2
|
| 3 |
albumentations>=1.4.0
|
| 4 |
Pillow>=10.0.0
|
|
|
|
| 1 |
+
gradio>=6.5.0
|
| 2 |
numpy<2
|
| 3 |
albumentations>=1.4.0
|
| 4 |
Pillow>=10.0.0
|