iespsurmreqmer commited on
Commit
43a3eff
·
1 Parent(s): 830bb49

Commit sin el token

Browse files
Files changed (7) hide show
  1. .gitignore +1 -1
  2. .gitignore copy +3 -0
  3. app.py +23 -0
  4. app2.py +38 -0
  5. app3.py +0 -0
  6. app_prueba.py +28 -0
  7. requirements.txt +3 -0
.gitignore CHANGED
@@ -1,3 +1,3 @@
1
- /huggingvenv
2
 
3
  .venv
 
1
+ huggingvenv/
2
 
3
  .venv
.gitignore copy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ huggingvenv/
2
+
3
+ .venv
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ from transformers import pipeline
4
+
5
+ captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
6
+
7
+ def describir(imagen):
8
+ if imagen is None:
9
+ return "Sube una imagen."
10
+
11
+ img = Image.fromarray(imagen)
12
+ result = captioner(img)[0]["generated_text"]
13
+ return result
14
+
15
+ demo = gr.Interface(
16
+ fn=describir,
17
+ inputs=gr.Image(type="numpy"),
18
+ outputs=gr.Textbox(),
19
+ title="Accesibilidad con Transformers",
20
+ description="Sube una imagen y un modelo Transformer generará una descripción detallada."
21
+ )
22
+
23
+ demo.launch()
app2.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+
5
+ generator = pipeline(
6
+ "text2text-generation",
7
+ model="google/flan-t5-small"
8
+ )
9
+
10
+ def career_advice(age, academic_level, interests, needs_income):
11
+ prompt = f"""
12
+ You are an expert career advisor. A student has the following data:
13
+ - Age: {age}
14
+ - Academic level: {academic_level}
15
+ - Interests: {interests}
16
+ - Needs income: {needs_income}
17
+ Give a clear, realistic, and motivating recommendation about whether the student should:
18
+ - Continue studying
19
+ - Do vocational training (FP)
20
+ - Start working
21
+ Explain the reasoning behind your recommendation.
22
+ """
23
+ result = generator(prompt, max_length=200)
24
+ return result[0]['generated_text']
25
+
26
+ interface = gr.Interface(
27
+ fn=career_advice,
28
+ inputs=[
29
+ gr.Number(label="Age"),
30
+ gr.Textbox(label="Academic level"),
31
+ gr.Textbox(label="Interests"),
32
+ gr.Dropdown(choices=["Yes", "No"], label="Needs income")
33
+ ],
34
+ outputs=gr.Textbox(label="Recommendation"),
35
+ title="Career Advisor for Students"
36
+ )
37
+
38
+ interface.launch()
app3.py ADDED
File without changes
app_prueba.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ clasificador = pipeline("sentiment-analysis", model="pysentimiento/robertuito-sentiment-analysis")
5
+
6
+ def puntuacion_sentimientos(texto):
7
+ resultado = clasificador(texto)
8
+ print(resultado)
9
+ etiqueta = resultado[0]["label"]
10
+ if(etiqueta == "POS"):
11
+ respuesta = "Tu frase muy positiva"
12
+ elif etiqueta == "NEG":
13
+ respuesta = "Tu frase muy negativa"
14
+ else:
15
+ respuesta = "ni fu ni fa"
16
+ return respuesta
17
+
18
+ demo = gr.Interface(
19
+ fn=puntuacion_sentimientos,
20
+ inputs=gr.Textbox(),
21
+ outputs=gr.Textbox(),
22
+ title="Ejemplo Sentimientos de las frases",
23
+ description="Esta es nuestra interfaz para probar <strong>modelos de UA</strong>",
24
+ article="En este modelo, escribe una frase y pulsa en **Comprobar** para ver si tiene sentimientos positivos, negativos o neutros",
25
+ submit_btn="comprobar",
26
+ fill_width=True
27
+ )
28
+ demo.launch(theme=gr.themes.Soft())
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers==4.49.0
3
+ torch==2.6.0