Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,21 @@
|
|
1 |
-
import os
|
2 |
from transformers import pipeline
|
3 |
-
|
4 |
|
5 |
-
# Obt茅n tu clave de acceso de Hugging Face
|
6 |
-
access_token = os.environ.get("app.py")
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# Resto del c贸digo...
|
15 |
-
|
16 |
-
def infer_gender(name):
|
17 |
-
"""
|
18 |
-
Infiere el g茅nero de una persona a partir de su nombre.
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
Returns:
|
24 |
-
str: El g茅nero predicho ('Male' o 'Female').
|
25 |
-
"""
|
26 |
-
# Hacer la predicci贸n utilizando el modelo cargado
|
27 |
-
prediction = gender_classifier([name])[0]
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
demo = gr.Interface(
|
33 |
-
fn=infer_gender,
|
34 |
-
inputs=gr.Textbox(label="Nombre"),
|
35 |
-
outputs=gr.Label(label="G茅nero predicho"),
|
36 |
-
title="Clasificador de G茅nero",
|
37 |
-
description="Ingresa un nombre para predecir su g茅nero."
|
38 |
-
)
|
39 |
-
|
40 |
-
# Ejecutar la aplicaci贸n
|
41 |
-
demo.launch(share=True)
|
42 |
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
|
|
|
|
|
4 |
|
5 |
+
generator = pipeline("image-to-image", model="microsoft/age-recognition")
|
6 |
+
def generate_face_variations(image):
|
7 |
+
variations = generator(image, num_images=4, guidance_scale=7.5)
|
8 |
+
return variations
|
9 |
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
gr.Markdown("# Face Position Variation Generator")
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
with gr.Row():
|
14 |
+
input_image = gr.Image(type="pil")
|
15 |
+
output_gallery = gr.Gallery().style(grid=2, height="auto")
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
generate_btn = gr.Button("Generate")
|
18 |
+
|
19 |
+
generate_btn.click(fn=generate_face_variations, inputs=input_image, outputs=output_gallery)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
demo.launch()
|