Spaces:
Runtime error
Runtime error
hamdanhh07
commited on
Commit
•
510d63d
1
Parent(s):
30aa54f
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from datasets import load_dataset
|
4 |
-
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
5 |
-
from transformers import ViTFeatureExtractor, ViTForImageClassification
|
6 |
from PIL import Image
|
|
|
7 |
import requests
|
8 |
-
extractor = AutoFeatureExtractor.from_pretrained("google/vit-base-patch16-224")
|
9 |
-
model = AutoModelForImageClassification.from_pretrained("google/vit-base-patch16-224")
|
10 |
-
|
11 |
dataset = load_dataset("hamdan07/UltraSound-lung")
|
12 |
-
image = Image.open(requests.get(dataset, stream=True).raw)
|
13 |
-
feature_extractor = ViTFeatureExtractor.from_pretrained('google/vit-base-patch16-224')
|
14 |
-
model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
|
15 |
-
inputs = feature_extractor(images=image, return_tensors="pt")
|
16 |
-
outputs = model(**inputs)
|
17 |
-
logits = outputs.logits
|
18 |
-
predicted_class_idx = logits.argmax(-1).item()
|
19 |
-
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
20 |
API_URL = "https://api-inference.huggingface.co/models/hamdan07/UltraSound-Lung"
|
21 |
headers = {"Authorization": "Bearer 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"}
|
|
|
|
|
22 |
|
23 |
def query(filename):
|
24 |
with open(filename, "rb") as f:
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from datasets import load_dataset
|
|
|
|
|
4 |
from PIL import Image
|
5 |
+
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
6 |
import requests
|
|
|
|
|
|
|
7 |
dataset = load_dataset("hamdan07/UltraSound-lung")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
API_URL = "https://api-inference.huggingface.co/models/hamdan07/UltraSound-Lung"
|
9 |
headers = {"Authorization": "Bearer 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"}
|
10 |
+
extractor = AutoFeatureExtractor.from_pretrained("google/vit-base-patch16-224")
|
11 |
+
model = AutoModelForImageClassification.from_pretrained("google/vit-base-patch16-224")
|
12 |
|
13 |
def query(filename):
|
14 |
with open(filename, "rb") as f:
|