AMfeta99 commited on
Commit
369329c
1 Parent(s): d535090

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # make the image classification pipeline
6
+ def classify_image(test_sample):
7
+ img_class= pipeline(
8
+ "image-classification", model="AMfeta99/vit-base-oxford-brain-tumor"
9
+ )
10
+ results = img_class(our_dataset['test']['image'][0])
11
+ max_score_result = max(results, key=lambda x: x['score'])
12
+
13
+ predictions = max_score_result['label']
14
+
15
+ return predictions
16
+
17
+
18
+
19
+ image = gr.Image()
20
+ label = gr.Label(num_top_classes=1)
21
+ title = "Brain Tumor X-ray Classification"
22
+ description="Worried about whether your brain scan is normal or not? Upload your x-ray and the algorithm will give you an expert opinion. Check out [the original algorithm](https://huggingface.co/AMfeta99/vit-base-oxford-brain-tumor) that this demo is based off of."
23
+ article="<p style='text-align: center'>Image Classification | Demo Model</p>"
24
+ demo = gr.Interface(fn=classify_image, inputs=image , outputs=label, description=description,article=article,title=title)
25
+
26
+ demo.launch(share=True)