abdoulayegk commited on
Commit
c32a3c5
1 Parent(s): 427c841

initial commit

Browse files
Files changed (3) hide show
  1. app.py +29 -0
  2. demo1.py +10 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from _typeshed import OpenBinaryModeUpdating
2
+ from types import resolve_bases
3
+ import requests
4
+ import gradio as gr
5
+ import torch
6
+ from timm import create_model
7
+ from tim.data import reslove_data_config
8
+ from timm.data.transformer import create_transform
9
+
10
+ IMAGENET_1k_URL = "https://storage.googleapis.com/bit_models/ilsvrc2012_wordnet_lemmas.txt"
11
+ LABELS = requests.get(IMAGENET_1k_URL).text.strip().split('\n')
12
+
13
+ model = create_model('restnet50',pretrained=True)
14
+
15
+ transofrm = create_transform(**resolve_data_config{}, model=model)
16
+
17
+ model.eval()
18
+
19
+ def predict_fn(img):
20
+ img = img.convert('RGB')
21
+ img = transofrm(img).unsqueez(0)
22
+
23
+ with torch.no_grad():
24
+ out = model(img)
25
+ probabilites = torch.nn.functional.softmax(out[0], dim=0)
26
+
27
+ values , indices = torch.topk(probabilites, k=5)
28
+
29
+ # return
demo1.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio import inputs
3
+
4
+
5
+ def greet(name):
6
+ return "Hello " + name + "!!"
7
+
8
+
9
+ ui = gr.Interface(greet, inputs="text", outputs="text")
10
+ ui.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ timm