Amanda Sarubbi commited on
Commit
0a80f0d
·
1 Parent(s): de2563a
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -39,14 +39,23 @@ def predict(img, model_name):
39
  geo_learn = import_model('geo_model.pkl')
40
  pred = geo_learn.predict(img)[0]
41
  labels = geo
 
 
 
42
  elif (model_name == 'Scenery, Natural Phenomena'):
43
  landscape_learn = import_model('landscape_model.pkl')
44
  pred = landscape_learn.predict(img)[0]
45
  labels = scen
 
 
 
46
  elif (model_name == 'Human & Supernatural Beings'):
47
  human_learn = import_model('human_model.pkl')
48
  pred = human_learn.predict(img)[0]
49
  labels = char
 
 
 
50
  elif (model_name == 'Colors & Characters'):
51
  colors_learn = import_model('colors_model.pkl')
52
  pred = colors_learn.predict(img)[0]
@@ -68,15 +77,11 @@ def predict(img, model_name):
68
  pred = str(pred)
69
  fix_pred = pred[4:-4]
70
  return fix_pred
71
-
72
- pred = str(pred)
73
- fix_pred = pred[4:-4]
74
- return fix_pred + ", Design Codes: " + labels[fix_pred]
75
  #########################################################################
76
  title = "TM-TKO Trademark Logo Image Classification Model"
77
  description = "Users can upload an image and corresponding image file name to get US design-code standard predictions on a trained model that utilizes the benchmark ResNet50 architecture."
78
  iFace = gr.Interface(fn=predict,
79
- inputs=[gr.inputs.Image(label="Upload Logo Here"), gr.inputs.Dropdown(choices=['Geometric Figures & Solids', 'Scenery, Natural Phenomena', 'Human & Supernatural Beings', 'Colors & Characters', 'Buildings, Dwellings & Furniture', 'Animals', 'All'], label='Choose a Model')],
80
  outputs=gr.Label(label="TM-TKO Trademark Classification Model"),
81
  title=title, description=description)
82
  iFace.launch()
 
39
  geo_learn = import_model('geo_model.pkl')
40
  pred = geo_learn.predict(img)[0]
41
  labels = geo
42
+ pred = str(pred)
43
+ fix_pred = pred[4:-4]
44
+ return fix_pred + ", Design Codes: " + labels[fix_pred]
45
  elif (model_name == 'Scenery, Natural Phenomena'):
46
  landscape_learn = import_model('landscape_model.pkl')
47
  pred = landscape_learn.predict(img)[0]
48
  labels = scen
49
+ pred = str(pred)
50
+ fix_pred = pred[4:-4]
51
+ return fix_pred + ", Design Codes: " + labels[fix_pred]
52
  elif (model_name == 'Human & Supernatural Beings'):
53
  human_learn = import_model('human_model.pkl')
54
  pred = human_learn.predict(img)[0]
55
  labels = char
56
+ pred = str(pred)
57
+ fix_pred = pred[4:-4]
58
+ return fix_pred + ", Design Codes: " + labels[fix_pred]
59
  elif (model_name == 'Colors & Characters'):
60
  colors_learn = import_model('colors_model.pkl')
61
  pred = colors_learn.predict(img)[0]
 
77
  pred = str(pred)
78
  fix_pred = pred[4:-4]
79
  return fix_pred
 
 
 
 
80
  #########################################################################
81
  title = "TM-TKO Trademark Logo Image Classification Model"
82
  description = "Users can upload an image and corresponding image file name to get US design-code standard predictions on a trained model that utilizes the benchmark ResNet50 architecture."
83
  iFace = gr.Interface(fn=predict,
84
+ inputs=[gr.inputs.Image(label="Upload Logo Here"), gr.inputs.Dropdown(choices=['Geometric Figures & Solids', 'Scenery, Natural Phenomena', 'Human & Supernatural Beings', 'Colors & Characters', 'Buildings, Dwellings & Furniture', 'Animals'], label='Choose a Model')],
85
  outputs=gr.Label(label="TM-TKO Trademark Classification Model"),
86
  title=title, description=description)
87
  iFace.launch()