kamalcst commited on
Commit
4d751db
1 Parent(s): 07528b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -29
app.py CHANGED
@@ -1,33 +1,6 @@
1
  import gradio as gr
2
- from transformers import AutoModelForImageClassification, AutoProcessor
3
- import torch
4
 
5
  # Load the model and processor from Hugging Face
6
- model_name = "dima806/facial_age_image_detection"
7
- model = AutoModelForImageClassification.from_pretrained(model_name)
8
- processor = AutoProcessor.from_pretrained(model_name)
9
-
10
- # Define the prediction function
11
- def predict(image):
12
- # Process the input image
13
- inputs = processor(images=image, return_tensors="pt")
14
- # Perform the prediction
15
- with torch.no_grad():
16
- outputs = model(**inputs)
17
-
18
- # Return the model's original outputs (e.g., logits or probabilities)
19
- predictions = outputs.logits
20
-
21
- return predictions
22
-
23
- # Create Gradio interface
24
- iface = gr.Interface(
25
- fn=predict,
26
- inputs="image",
27
- outputs="label", # Use the model's original output type
28
- title="Facial Age Prediction",
29
- description="This application predicts your age from a facial image."
30
- )
31
-
32
  # Launch the Gradio application
33
- iface.launch(share=True)
 
1
  import gradio as gr
 
 
2
 
3
  # Load the model and processor from Hugging Face
4
+ model = "dima806/facial_age_image_detection"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  # Launch the Gradio application
6
+ model.launch(share=True)