I implemented the dogs vs cats code to what am working in (image classification), I followed step by step but when uploading image to get whether the image is dogs (normal) or cats (abnormal) the output doesn’t show
Code Sample:
test_img = test_img.resize((W,H), resample=PIL.Image.BICUBIC)
test_arr = img_to_array(test_img)
test_arr = np.expand_dims(test_arr, axis=0)
test_arr /= 255.0
plt.imshow(test_img)
score = model.predict(test_arr)
label = np.argmax(score,axis=1)
print(score)
if label < 0.5:
print("Abnormal")
else:
print("Normal")
![Capture.PNG anvil|326x286](upload://uGHCqHFuenPRcKzf3MGbJGjUnC6.png)
import anvil.server
anvil.server.connect(" ...")
import anvil.media
@anvil.server.callable
def classify_image(file):
with anvil.media.TempFile(file) as filename:
img = load_img(filename)
img = img.resize((W,H), resample=PIL.image.BICUBIC)
arr = img_to_array(img)
arr = np.expand_dims(arr, axis=0)
arr /= 255.0
score= model.predict(arr)
label = np.argmax(score,axis=1)
return score, "abnormal" if label < 0.5 else "normal"
(code from my jupyter notebook)
i will really appreciate if someone helps!
Clone link:
share a copy of your app