Spaces:
Build error
Build error
Update app.py
Browse files5 unmodified lines678991011125 unmodified lines18192021222324212223245 unmodified linesfrom transformers import pipeline
def predict_image(image): pipe = pipeline("image-classification", model="itsTomLie/genders_microsoft_resnet50") pipe = pipeline("image-classification", model="rizvandwiki/gender-classification")
if isinstance(image, np.ndarray): image = Image.fromarray(image.astype('uint8'))5 unmodified lines label = result[0]['label'] confidence = result[0]['score']
prediction = 'female' if label == 'LABEL_0' else 'male' print(f"Prediction: {prediction}, Confidence: {confidence}")
return prediction, confidence return label, confidence
example_images = [ os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))app.py+2-5