Spaces:
Runtime error
Runtime error
Download app.py from abdabbas/abd: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/abdabbas/abd/resolve/9e65f0007541e84627e4da17060b6233edf453dc/app.py
- Command line
-
hf download hf://spaces/abdabbas/abd@9e65f0007541e84627e4da17060b6233edf453dc/app.py
-
curl -L -o app.py https://huggingface.co/spaces/abdabbas/abd/resolve/9e65f0007541e84627e4da17060b6233edf453dc/app.py
1.08 kB
| #!pip install gradio | |
| import os | |
| import shutil | |
| import glob | |
| from tqdm.notebook import tqdm | |
| import numpy as np | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import tensorflow as tf | |
| from tensorflow import keras | |
| import cv2 | |
| from PIL import Image | |
| from tensorflow.keras.preprocessing.image import ImageDataGenerator | |
| import random | |
| from random import seed | |
| #from livelossplot import PlotLossesKeras | |
| import math | |
| from tensorflow.keras.metrics import Recall,Precision,AUC | |
| from keras.models import load_model | |
| model = load_model('target_xception_model.h5') | |
| class_names={0:'خبيث',1:'حميد'} | |
| def predict_image(img): | |
| img_4d=img.reshape(-1,299,299,3) | |
| img_4d=img_4d/255 | |
| prediction=model.predict(img_4d)[0] | |
| #prediction = [1 if x>0.5 else 0 for x in prediction] | |
| return {class_names[i]: float(prediction[i]) for i in range(1)} | |
| import gradio as gr | |
| image = gr.inputs.Image(shape=(299,299)) | |
| label = gr.outputs.Label(num_top_classes=1) | |
| gr.Interface(fn=predict_image, inputs=image, | |
| outputs=label).launch(debug='False',share=True) |