Spaces:
Sleeping
Sleeping
Commit
·
16477d5
1
Parent(s):
d595dfc
Changed from plot output to img ?
Browse files
app.py
CHANGED
@@ -139,7 +139,12 @@ def inference(query, labels, n_supp=10,
|
|
139 |
|
140 |
probs = output.softmax(dim=-1).detach().cpu().numpy()
|
141 |
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
|
145 |
# DEBUG
|
|
|
139 |
|
140 |
probs = output.softmax(dim=-1).detach().cpu().numpy()
|
141 |
|
142 |
+
# it used to be a matplotlib figure, turning it into a PIL image
|
143 |
+
fig.canvas.draw()
|
144 |
+
w, h = fig.canvas.get_width_height()
|
145 |
+
img = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8).reshape(h, w, 3)
|
146 |
+
return {k: float(v) for k, v in zip(labels, probs[0, 0])}, Image.fromarray(img)
|
147 |
+
#return {k: float(v) for k, v in zip(labels, probs[0, 0])}, fig
|
148 |
|
149 |
|
150 |
# DEBUG
|