LPX55 commited on
Commit
17c8406
·
verified ·
1 Parent(s): 433b282

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  # from transformers import AutoBackbone, AutoModelForImageClassification, AutoImageProcessor, Swinv2ForImageClassification
3
- from transformers import pipeline, AutoImageProcessor, Swinv2ForImageClassification, Swinv2Model
4
  from torchvision import transforms
5
 
6
  # model = AutoModelForImageClassification.from_pretrained("haywoodsloan/ai-image-detector-deploy")
@@ -17,6 +17,8 @@ def predict_image(img):
17
  img = transforms.ToPILImage()(img)
18
  img = transforms.Resize((256,256))(img)
19
  prediction=clf.predict(img)
 
 
20
  return {class_names[i]: float(prediction[i]["score"]) for i in range(2)}
21
 
22
  image = gr.Image(label="Image to Analyze", sources=['upload'])
 
1
  import gradio as gr
2
  # from transformers import AutoBackbone, AutoModelForImageClassification, AutoImageProcessor, Swinv2ForImageClassification
3
+ from transformers import pipeline, AutoImageProcessor, Swinv2ForImageClassification
4
  from torchvision import transforms
5
 
6
  # model = AutoModelForImageClassification.from_pretrained("haywoodsloan/ai-image-detector-deploy")
 
17
  img = transforms.ToPILImage()(img)
18
  img = transforms.Resize((256,256))(img)
19
  prediction=clf.predict(img)
20
+ print(clf(image))
21
+ print(model.config.id2label[predicted_label])
22
  return {class_names[i]: float(prediction[i]["score"]) for i in range(2)}
23
 
24
  image = gr.Image(label="Image to Analyze", sources=['upload'])