Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from PIL import Image | |
| from vit_model_test import CustomModel | |
| # Initialize the model | |
| model = CustomModel() | |
| def predict(image: Image.Image): | |
| animation.visible = True # 讛专讗讛 讗转 讛讗谞讬诪爪讬讛 | |
| label, confidence = model.predict(image) | |
| result = "AI image" if label == 1 else "Real image" | |
| animation.visible = False # 讛住转专 讗转 讛讗谞讬诪爪讬讛 | |
| return result, f"Confidence: {confidence:.2f}%" | |
| # Define the Gradio interface | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil"), | |
| outputs=[gr.Textbox(), gr.Textbox()], | |
| title="Vision Transformer Model", | |
| description="Upload an image to classify it using the Vision Transformer model.", | |
| live=True, # 诪讗驻砖专 讞讬讝讜讬 诪讬讬讚讬 | |
| ) | |
| # Add video component | |
| animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=False) # 讛讻谞讬住讬 讗转 讛-URL 讛谞讻讜谉 | |
| # Launch the Gradio interface | |
| if __name__ == "__main__": | |
| demo.launch() | |