Spaces:
Runtime error
Runtime error
Download efficientNet-algo/EfficientNet-model/example.py from NexNoor/PoultryShieldAI: direct link, hf CLI and curl.
- Browser
- Download file 595 Bytes
-
https://huggingface.co/spaces/NexNoor/PoultryShieldAI/resolve/main/efficientNet-algo/EfficientNet-model/example.py
- Command line
-
hf download hf://spaces/NexNoor/PoultryShieldAI/efficientNet-algo/EfficientNet-model/example.py
-
curl -L -o example.py https://huggingface.co/spaces/NexNoor/PoultryShieldAI/resolve/main/efficientNet-algo/EfficientNet-model/example.py
595 Bytes
| # TF for image classification model | |
| import tensorflow | |
| import numpy | |
| from PIL import Image | |
| model = tensorflow.saved_model.load('./') | |
| classes = [ "Coccidiosis" , "Healthy poultry" , "New castle diseases" , "Salmonella" , ] | |
| img = Image.open("image.jpg").convert('RGB') | |
| img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS) | |
| inp_numpy = numpy.array(img)[None] | |
| inp = tensorflow.constant(inp_numpy, dtype='float32') | |
| class_scores = model(inp)[0].numpy() | |
| print("") | |
| print("class_scores", class_scores) | |
| print("Class : ", classes[class_scores.argmax()]) |