vincentb25 commited on
Commit
b7dcf43
·
1 Parent(s): 57b7888

Added requirements to work locally, and changed channel for img out

Browse files
Files changed (2) hide show
  1. app.py +5 -1
  2. requirements.txt +2 -0
app.py CHANGED
@@ -143,7 +143,11 @@ def inference(query, labels, n_supp=10,
143
  fig.canvas.draw()
144
  w, h = fig.canvas.get_width_height()
145
  img = np.frombuffer(fig.canvas.tostring_argb(), dtype=np.uint8).reshape(h, w, 4)
146
- img = img[:, :, :3]
 
 
 
 
147
  return {k: float(v) for k, v in zip(labels, probs[0, 0])}, Image.fromarray(img)
148
  #return {k: float(v) for k, v in zip(labels, probs[0, 0])}, fig
149
 
 
143
  fig.canvas.draw()
144
  w, h = fig.canvas.get_width_height()
145
  img = np.frombuffer(fig.canvas.tostring_argb(), dtype=np.uint8).reshape(h, w, 4)
146
+
147
+ # The image is all red, we are probably not cutting the alpha channel
148
+ #img = img[:, :, :3]
149
+ img = img[:, :, 1:4] # remove alpha channel
150
+
151
  return {k: float(v) for k, v in zip(labels, probs[0, 0])}, Image.fromarray(img)
152
  #return {k: float(v) for k, v in zip(labels, probs[0, 0])}, fig
153
 
requirements.txt CHANGED
@@ -10,3 +10,5 @@ ml-collections
10
  ftfy
11
  tensorboard
12
  Google-Images-Search
 
 
 
10
  ftfy
11
  tensorboard
12
  Google-Images-Search
13
+ semantic-version
14
+ pytz