runaksh commited on
Commit
02040fb
·
verified ·
1 Parent(s): 1edb920

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -4,16 +4,20 @@ import requests
4
 
5
  feature_extractor = ViTFeatureExtractor.from_pretrained('google/vit-base-patch16-224-in21k')
6
  loaded_model = ViTModel.from_pretrained("runaksh/chest_xray_pneumonia_detection")
7
- inputs = feature_extractor(images=image, return_tensors="pt")
8
 
9
- pipe = pipeline('image-classification', model=model_name, device=0)
 
 
 
 
10
 
11
  # Create title, description and article strings
12
  title = "Classification Demo"
13
  description = "XRay classification"
14
 
15
  # Create the Gradio demo
16
- demo = gr.Interface(fn=pipe, # mapping function from input to output
17
  inputs=gr.Image(type='filepath'), # what are the inputs?
18
  outputs=[gr.Label(label="Predictions"), # what are the outputs?
19
  gr.Number(label="Prediction time (s)")], # our fn has two outputs, therefore we have two outputs
 
4
 
5
  feature_extractor = ViTFeatureExtractor.from_pretrained('google/vit-base-patch16-224-in21k')
6
  loaded_model = ViTModel.from_pretrained("runaksh/chest_xray_pneumonia_detection")
7
+ #inputs = feature_extractor(images=image, return_tensors="pt")
8
 
9
+ def predict(img):
10
+ #inputs = feature_extractor(images=image, return_tensors="pt")
11
+ pipe = pipeline('image-classification', model=model_name, device=0)
12
+ pred = pipe(image)
13
+ return pred
14
 
15
  # Create title, description and article strings
16
  title = "Classification Demo"
17
  description = "XRay classification"
18
 
19
  # Create the Gradio demo
20
+ demo = gr.Interface(fn=predict, # mapping function from input to output
21
  inputs=gr.Image(type='filepath'), # what are the inputs?
22
  outputs=[gr.Label(label="Predictions"), # what are the outputs?
23
  gr.Number(label="Prediction time (s)")], # our fn has two outputs, therefore we have two outputs