Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,18 @@
|
|
1 |
-
import
|
2 |
-
import tensorflow as tf
|
3 |
|
|
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
"<center>"
|
9 |
-
"Upload an X-ray image to check for covid19. The app is for research purposes and not clinically authorized"
|
10 |
-
"</center>"
|
11 |
-
)
|
12 |
-
title = "Covid 19 Prediction App using X-ray Images"
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
"Upload an X-ray image to check for covid19. The app is for research purposes and not clinically authorized"
|
17 |
-
"</center>"
|
18 |
-
)
|
19 |
|
20 |
-
def
|
21 |
-
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
model = AutoModelForImageClassification.from_pretrained("swww/test")
|
26 |
-
|
27 |
-
|
28 |
-
image = gr.inputs.Image(shape=(500, 500), image_mode='L', invert_colors=False, source="upload")
|
29 |
-
label = gr.outputs.Label()
|
30 |
-
iface = gr.Interface(fn=predict_input_image, inputs=image, outputs=label,title=title, description=head)
|
31 |
-
iface.launch()
|
|
|
1 |
+
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
|
|
2 |
|
3 |
+
extractor = AutoFeatureExtractor.from_pretrained("swww/test")
|
4 |
|
5 |
+
model = AutoModelForImageClassification.from_pretrained("swww/test")
|
6 |
|
7 |
+
import requests
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
API_URL = "https://api-inference.huggingface.co/models/swww/test"
|
10 |
+
headers = {"Authorization": "Bearer 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"}
|
|
|
|
|
|
|
11 |
|
12 |
+
def query(filename):
|
13 |
+
with open(filename, "rb") as f:
|
14 |
+
data = f.read()
|
15 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
16 |
+
return response.json()
|
17 |
|
18 |
+
output = query("cats.jpg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|