Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
generator = pipeline('text-generation', model='
|
| 6 |
|
| 7 |
-
# Funzione
|
| 8 |
def genera_codice(input_text):
|
| 9 |
-
#
|
| 10 |
-
result = generator(input_text, max_length=
|
| 11 |
codice_generato = result[0]['generated_text']
|
| 12 |
return codice_generato
|
| 13 |
|
| 14 |
-
# Crea l'interfaccia utente
|
| 15 |
-
iface = gr.Interface(fn=genera_codice,
|
| 16 |
-
inputs="text", # Tipo di input
|
| 17 |
-
outputs="text", # Tipo di output
|
| 18 |
-
live=False, #
|
| 19 |
-
title="
|
| 20 |
-
description="
|
| 21 |
|
| 22 |
-
# Avvia l'
|
| 23 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Usa un modello più piccolo e veloce, come distilgpt2
|
| 5 |
+
generator = pipeline('text-generation', model='distilgpt2')
|
| 6 |
|
| 7 |
+
# Funzione per generare il codice C
|
| 8 |
def genera_codice(input_text):
|
| 9 |
+
# Genera il codice in base alla descrizione data
|
| 10 |
+
result = generator(input_text, max_length=100, num_return_sequences=1)
|
| 11 |
codice_generato = result[0]['generated_text']
|
| 12 |
return codice_generato
|
| 13 |
|
| 14 |
+
# Crea l'interfaccia utente
|
| 15 |
+
iface = gr.Interface(fn=genera_codice,
|
| 16 |
+
inputs="text", # Tipo di input: campo di testo
|
| 17 |
+
outputs="text", # Tipo di output: campo di testo
|
| 18 |
+
live=False, # Impostato a False per il tasto "Submit"
|
| 19 |
+
title="Bakloul.AI", # Titolo della pagina
|
| 20 |
+
description="Inserisci una descrizione per generare il tuo codice in C")
|
| 21 |
|
| 22 |
+
# Avvia l'interfaccia
|
| 23 |
iface.launch()
|