Delete app.py
Browse files
app.py
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
import gradio as gr
|
3 |
-
from torchvision import transforms
|
4 |
-
from PIL import Image
|
5 |
-
|
6 |
-
# Load model
|
7 |
-
class MyModel(torch.nn.Module):
|
8 |
-
def __init__(self):
|
9 |
-
super().__init__()
|
10 |
-
# Define layers here
|
11 |
-
|
12 |
-
def forward(self, x):
|
13 |
-
# Forward pass
|
14 |
-
return x
|
15 |
-
|
16 |
-
model = MyModel()
|
17 |
-
model.load_state_dict(torch.load("model.pth"))
|
18 |
-
model.eval()
|
19 |
-
|
20 |
-
# Define image preprocessing
|
21 |
-
transform = transforms.Compose([
|
22 |
-
transforms.Resize((224, 224)),
|
23 |
-
transforms.ToTensor(),
|
24 |
-
])
|
25 |
-
|
26 |
-
# Define prediction function
|
27 |
-
def predict(image):
|
28 |
-
image = transform(image).unsqueeze(0) # Add batch dimension
|
29 |
-
with torch.no_grad():
|
30 |
-
output = model(image)
|
31 |
-
return output.numpy().tolist()
|
32 |
-
|
33 |
-
# Create Gradio interface
|
34 |
-
iface = gr.Interface(fn=predict, inputs=gr.Image(), outputs="json")
|
35 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|