litav commited on
Commit
40ee638
ยท
verified ยท
1 Parent(s): 3f9b377

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
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
- # Define the Gradio interface
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 using the Vision Transformer model."
 
 
 
22
  )
23
 
 
 
24
 
25
- # Launch the Gradio interface
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()