Mishmosh commited on
Commit
2490569
·
1 Parent(s): 12c6bb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,14 +1,19 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
 
4
  image_classifier = pipeline("image-classification")
5
- image_path = "https://www.skinewgen.com/wp-content/uploads/20210301-New-Generation-91-2.jpg"
6
- result = image_classifier(image_path)
7
- print(result)
8
 
9
- model = gr.Interface.load("huggingface/google/vit-base-patch16-224")
 
 
 
10
 
11
- model.launch()
 
 
 
 
12
 
13
 
14
 
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # Load image classification pipeline from Hugging Face Transformers
5
  image_classifier = pipeline("image-classification")
 
 
 
6
 
7
+ # Define a function for image classification using Gradio
8
+ def classify_image(image_path):
9
+ result = image_classifier(image_path)
10
+ return result[0]['label'] # Return the label of the top prediction
11
 
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(fn=classify_image, inputs="image", outputs="text")
14
+
15
+ # Launch the Gradio interface
16
+ iface.launch()
17
 
18
 
19