Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,21 +6,25 @@ from vit_model_test import CustomModel
|
|
| 6 |
model = CustomModel()
|
| 7 |
|
| 8 |
def predict(image: Image.Image):
|
| 9 |
-
|
| 10 |
label, confidence = model.predict(image)
|
| 11 |
result = "AI image" if label == 1 else "Real image"
|
| 12 |
return result, f"Confidence: {confidence:.2f}%"
|
| 13 |
-
|
| 14 |
|
| 15 |
-
#
|
| 16 |
demo = gr.Interface(
|
| 17 |
fn=predict,
|
| 18 |
inputs=gr.Image(type="pil"),
|
| 19 |
outputs=[gr.Textbox(), gr.Textbox()],
|
| 20 |
title="Vision Transformer Model",
|
| 21 |
-
description="Upload an image to classify it
|
|
|
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
demo.launch()
|
|
|
|
| 6 |
model = CustomModel()
|
| 7 |
|
| 8 |
def predict(image: Image.Image):
|
| 9 |
+
# ืืื ืืชืืฆืข ืขืืืื ืืชืืื ื
|
| 10 |
label, confidence = model.predict(image)
|
| 11 |
result = "AI image" if label == 1 else "Real image"
|
| 12 |
return result, f"Confidence: {confidence:.2f}%"
|
|
|
|
| 13 |
|
| 14 |
+
# ืืฆืืจืช ืืืฉืง Gradio ืขื ืืืืื ืฉืืืฆื ืืืื ืืืฉืื ืืืืื
|
| 15 |
demo = gr.Interface(
|
| 16 |
fn=predict,
|
| 17 |
inputs=gr.Image(type="pil"),
|
| 18 |
outputs=[gr.Textbox(), gr.Textbox()],
|
| 19 |
title="Vision Transformer Model",
|
| 20 |
+
description="Upload an image to classify it as AI-generated or Real.",
|
| 21 |
+
live=True, # ืืืคืฉืจ ืืืฆืื ืกืืืืก ืืืื ืืืช
|
| 22 |
+
theme="compact", # ืืคืฉืจื ืืืืกืืฃ ืขืืฆืื ืืงืฆืืขื
|
| 23 |
+
css=".loading-message { display: none; }"
|
| 24 |
)
|
| 25 |
|
| 26 |
+
# ืืืืจืช ืืกืจืืื ืฉืืืคืืข ืืืื ืืืฉืื
|
| 27 |
+
demo.loading = "https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4" # ืืืกืฃ ืืช ืฉื ืงืืืฅ ืืืืืืื
|
| 28 |
|
| 29 |
+
# ืืฉืงืช ืืืืฉืง
|
| 30 |
+
demo.launch()
|