Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,7 +26,6 @@ clf_2 = pipeline("image-classification", model=model_2_path)
|
|
| 26 |
class_names_1 = ['artificial', 'real']
|
| 27 |
class_names_2 = ['AI Image', 'Real Image'] # Adjust if the second model has different classes
|
| 28 |
|
| 29 |
-
|
| 30 |
def predict_image(img, confidence_threshold):
|
| 31 |
# Ensure the image is a PIL Image
|
| 32 |
if not isinstance(img, Image.Image):
|
|
@@ -94,10 +93,11 @@ image = gr.Image(label="Image to Analyze", sources=['upload'], type='pil') # En
|
|
| 94 |
confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
|
| 95 |
label = gr.JSON(label="Model Predictions")
|
| 96 |
|
| 97 |
-
|
|
|
|
| 98 |
fn=predict_image,
|
| 99 |
inputs=[image, confidence_slider],
|
| 100 |
outputs=label,
|
| 101 |
-
title="AI Generated Classification"
|
| 102 |
-
|
| 103 |
-
|
|
|
|
| 26 |
class_names_1 = ['artificial', 'real']
|
| 27 |
class_names_2 = ['AI Image', 'Real Image'] # Adjust if the second model has different classes
|
| 28 |
|
|
|
|
| 29 |
def predict_image(img, confidence_threshold):
|
| 30 |
# Ensure the image is a PIL Image
|
| 31 |
if not isinstance(img, Image.Image):
|
|
|
|
| 93 |
confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
|
| 94 |
label = gr.JSON(label="Model Predictions")
|
| 95 |
|
| 96 |
+
# Launch the interface with queuing enabled
|
| 97 |
+
iface = gr.Interface(
|
| 98 |
fn=predict_image,
|
| 99 |
inputs=[image, confidence_slider],
|
| 100 |
outputs=label,
|
| 101 |
+
title="AI Generated Classification"
|
| 102 |
+
)
|
| 103 |
+
iface.launch(queue=True)
|