Wootang01 commited on
Commit
b1c52f2
1 Parent(s): aee65ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -6,6 +6,11 @@ from timm import create_model
6
  from timm.data import resolve_data_config
7
  from timm.data.transforms_factory import create_transform
8
 
 
 
 
 
 
9
  IMAGENET_1K_URL = "https://storage.googleapis.com/bit_models/ilsvrc2012_wordnet_lemmas.txt"
10
  LABELS = requests.get(IMAGENET_1K_URL).text.strip().split("\n")
11
  model = create_model('resnet50', pretrained=True)
@@ -25,5 +30,10 @@ def predict_fn(img):
25
  values, indices = torch.topk(probabilities, k=3)
26
  return {LABELS[i]: v.item() for i, v in zip(indices, values)}
27
 
28
- gr.Interface(predict_fn, gr.inputs.Image(type='pil'), outputs='label').launch()
 
 
 
 
 
29
 
 
6
  from timm.data import resolve_data_config
7
  from timm.data.transforms_factory import create_transform
8
 
9
+ title = "Image Classifier Four -- Timm Resnet-50"
10
+ description = """This machine has vision. It can see objects and concepts in an image. To test the machine, upload or drop an image, submit and read the results. The results comprise a list of words that the machine sees in the image. Beside a word, the length of the bar indicates the confidence with which the machine sees the word. The longer the bar, the more confident the machine is.
11
+ """
12
+ article = "This app was made by following [this YouTube video](https://youtu.be/a8aS3ZYlzDM)."
13
+
14
  IMAGENET_1K_URL = "https://storage.googleapis.com/bit_models/ilsvrc2012_wordnet_lemmas.txt"
15
  LABELS = requests.get(IMAGENET_1K_URL).text.strip().split("\n")
16
  model = create_model('resnet50', pretrained=True)
 
30
  values, indices = torch.topk(probabilities, k=3)
31
  return {LABELS[i]: v.item() for i, v in zip(indices, values)}
32
 
33
+ gr.Interface(predict_fn,
34
+ gr.inputs.Image(type='pil'),
35
+ outputs='label',
36
+ title = title,
37
+ description = description,
38
+ article = article).launch()
39