Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,11 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
import open_clip
|
4 |
|
5 |
-
def predict(
|
6 |
device = torch.device("cpu")
|
7 |
model, _, preprocess = open_clip.create_model_and_transforms('ViT-L-14', pretrained='openai', device=device)
|
8 |
|
9 |
-
image = preprocess().unsqueeze(0).to(device)
|
10 |
|
11 |
with torch.amp.autocast(device_type=device.type):
|
12 |
with torch.no_grad():
|
@@ -20,5 +20,5 @@ def predict(image):
|
|
20 |
|
21 |
return "Map" if result == 1 else "No map"
|
22 |
|
23 |
-
demo = gr.Interface(fn=predict, inputs=gr.Image(label="
|
24 |
demo.launch()
|
|
|
2 |
import torch
|
3 |
import open_clip
|
4 |
|
5 |
+
def predict(input_image):
|
6 |
device = torch.device("cpu")
|
7 |
model, _, preprocess = open_clip.create_model_and_transforms('ViT-L-14', pretrained='openai', device=device)
|
8 |
|
9 |
+
image = preprocess(input_image).unsqueeze(0).to(device)
|
10 |
|
11 |
with torch.amp.autocast(device_type=device.type):
|
12 |
with torch.no_grad():
|
|
|
20 |
|
21 |
return "Map" if result == 1 else "No map"
|
22 |
|
23 |
+
demo = gr.Interface(fn=predict, inputs=gr.Image(label="Check whether the image is a map or not", type="pil"), outputs="text")
|
24 |
demo.launch()
|