Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,38 +6,11 @@ from vit_model_test import CustomModel
|
|
| 6 |
model = CustomModel()
|
| 7 |
|
| 8 |
def predict(image: Image.Image):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
return "Error in prediction", str(e)
|
| 15 |
-
|
| 16 |
-
# Custom HTML and CSS to replace the logo with a video
|
| 17 |
-
custom_html = """
|
| 18 |
-
<style>
|
| 19 |
-
/* Hide the default logo */
|
| 20 |
-
.gradio-logo {
|
| 21 |
-
display: none;
|
| 22 |
-
}
|
| 23 |
-
/* Center the video container */
|
| 24 |
-
.loading-container {
|
| 25 |
-
text-align: center;
|
| 26 |
-
margin-top: 20px;
|
| 27 |
-
}
|
| 28 |
-
.loading-container video {
|
| 29 |
-
width: 320px; /* Adjust video size */
|
| 30 |
-
height: auto; /* Maintain aspect ratio */
|
| 31 |
-
}
|
| 32 |
-
</style>
|
| 33 |
-
<div class="loading-container">
|
| 34 |
-
<video autoplay muted loop>
|
| 35 |
-
<source src="load_screen.mp4" type="video/mp4">
|
| 36 |
-
Your browser does not support the video tag.
|
| 37 |
-
</video>
|
| 38 |
-
<div>Processing, please wait...</div>
|
| 39 |
-
</div>
|
| 40 |
-
"""
|
| 41 |
|
| 42 |
# Define the Gradio interface
|
| 43 |
demo = gr.Interface(
|
|
@@ -48,8 +21,6 @@ demo = gr.Interface(
|
|
| 48 |
description="Upload an image to classify it using the Vision Transformer model."
|
| 49 |
)
|
| 50 |
|
| 51 |
-
# Inject the custom HTML to show the video instead of the logo
|
| 52 |
-
demo.load(custom_html)
|
| 53 |
|
| 54 |
# Launch the Gradio interface
|
| 55 |
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 |
|
| 15 |
# Define the Gradio interface
|
| 16 |
demo = gr.Interface(
|
|
|
|
| 21 |
description="Upload an image to classify it using the Vision Transformer model."
|
| 22 |
)
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Launch the Gradio interface
|
| 26 |
demo.launch()
|