abdoulayegk commited on
Commit
d44ec1b
·
1 Parent(s): c32a3c5

initial commit

Browse files
Files changed (1) hide show
  1. app.py +0 -29
app.py DELETED
@@ -1,29 +0,0 @@
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