Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -294,17 +294,18 @@ def process_parallel(tasks):
|
|
294 |
results = pool.map(lambda task: task(), tasks)
|
295 |
return results
|
296 |
|
297 |
-
def generate_response_from_prompt(prompt,
|
|
|
298 |
responses = generate_random_response([prompt], generator)
|
299 |
return responses[0]
|
300 |
|
301 |
-
def generate_image_from_prompt(prompt, image_type):
|
302 |
if image_type == "diffusers":
|
303 |
-
image = generate_diffusers_image_from_redis(
|
304 |
elif image_type == "stable-diffusion":
|
305 |
-
image = generate_stable_diffusion_image_from_redis(
|
306 |
elif image_type == "img2img":
|
307 |
-
image = generate_img2img_from_redis(
|
308 |
return image
|
309 |
|
310 |
def gradio_app():
|
@@ -314,36 +315,36 @@ def gradio_app():
|
|
314 |
prompt_text = gr.Textbox(label="Texto de Entrada")
|
315 |
text_output = gr.Textbox(label="Respuesta")
|
316 |
text_button = gr.Button("Generar Texto")
|
317 |
-
|
318 |
|
319 |
gr.Markdown("## Generaci贸n de Im谩genes con Diffusers, Stable Diffusion e Img2Img")
|
320 |
with gr.Row():
|
321 |
prompt_image = gr.Textbox(label="Prompt de Imagen")
|
322 |
image_type = gr.Dropdown(["diffusers", "stable-diffusion", "img2img"], label="Tipo de Imagen")
|
323 |
-
image_output = gr.Image(
|
324 |
image_button = gr.Button("Generar Imagen")
|
325 |
-
|
326 |
|
327 |
gr.Markdown("## Generaci贸n de Video")
|
328 |
with gr.Row():
|
329 |
prompt_video = gr.Textbox(label="Prompt de Video")
|
330 |
-
video_output = gr.Video(
|
331 |
video_button = gr.Button("Generar Video")
|
332 |
-
|
333 |
|
334 |
gr.Markdown("## Generaci贸n de Audio con MusicGen")
|
335 |
with gr.Row():
|
336 |
text_prompts_audio = gr.Textbox(label="Prompts de Audio")
|
337 |
-
audio_output = gr.Audio(
|
338 |
audio_button = gr.Button("Generar Audio")
|
339 |
-
|
340 |
|
341 |
gr.Markdown("## Transcripci贸n de Audio con Whisper")
|
342 |
with gr.Row():
|
343 |
-
audio_file = gr.Audio(type="
|
344 |
transcription_output = gr.Textbox(label="Transcripci贸n")
|
345 |
audio_button = gr.Button("Transcribir Audio")
|
346 |
-
|
347 |
|
348 |
gr.Markdown("## Traducci贸n de Texto")
|
349 |
with gr.Row():
|
@@ -352,16 +353,16 @@ def gradio_app():
|
|
352 |
src_lang_input = gr.Textbox(label="Idioma de Origen", value="en")
|
353 |
tgt_lang_input = gr.Textbox(label="Idioma de Destino", value="es")
|
354 |
translate_button = gr.Button("Traducir Texto")
|
355 |
-
|
356 |
|
357 |
gr.Markdown("## Resumen de Texto")
|
358 |
with gr.Row():
|
359 |
text_to_summarize = gr.Textbox(label="Texto para Resumir")
|
360 |
summary_output = gr.Textbox(label="Resumen")
|
361 |
summarize_button = gr.Button("Generar Resumen")
|
362 |
-
|
363 |
|
364 |
app.launch()
|
365 |
|
366 |
if __name__ == "__main__":
|
367 |
-
gradio_app()
|
|
|
294 |
results = pool.map(lambda task: task(), tasks)
|
295 |
return results
|
296 |
|
297 |
+
def generate_response_from_prompt(prompt, model_name="google/flan-t5-xl"):
|
298 |
+
generator = pipeline('text-generation', model=model_name, tokenizer=model_name)
|
299 |
responses = generate_random_response([prompt], generator)
|
300 |
return responses[0]
|
301 |
|
302 |
+
def generate_image_from_prompt(prompt, image_type, model_name):
|
303 |
if image_type == "diffusers":
|
304 |
+
image = generate_diffusers_image_from_redis(model_name, prompt)
|
305 |
elif image_type == "stable-diffusion":
|
306 |
+
image = generate_stable_diffusion_image_from_redis(model_name, prompt)
|
307 |
elif image_type == "img2img":
|
308 |
+
image = generate_img2img_from_redis(model_name, "init_image.png", prompt)
|
309 |
return image
|
310 |
|
311 |
def gradio_app():
|
|
|
315 |
prompt_text = gr.Textbox(label="Texto de Entrada")
|
316 |
text_output = gr.Textbox(label="Respuesta")
|
317 |
text_button = gr.Button("Generar Texto")
|
318 |
+
text_button.click(generate_response_from_prompt, inputs=prompt_text, outputs=text_output)
|
319 |
|
320 |
gr.Markdown("## Generaci贸n de Im谩genes con Diffusers, Stable Diffusion e Img2Img")
|
321 |
with gr.Row():
|
322 |
prompt_image = gr.Textbox(label="Prompt de Imagen")
|
323 |
image_type = gr.Dropdown(["diffusers", "stable-diffusion", "img2img"], label="Tipo de Imagen")
|
324 |
+
image_output = gr.Image(label="Imagen Generada")
|
325 |
image_button = gr.Button("Generar Imagen")
|
326 |
+
image_button.click(generate_image_from_prompt, inputs=[prompt_image, image_type], outputs=image_output)
|
327 |
|
328 |
gr.Markdown("## Generaci贸n de Video")
|
329 |
with gr.Row():
|
330 |
prompt_video = gr.Textbox(label="Prompt de Video")
|
331 |
+
video_output = gr.Video(label="Video Generado")
|
332 |
video_button = gr.Button("Generar Video")
|
333 |
+
video_button.click(generate_video_from_redis, inputs=prompt_video, outputs=video_output)
|
334 |
|
335 |
gr.Markdown("## Generaci贸n de Audio con MusicGen")
|
336 |
with gr.Row():
|
337 |
text_prompts_audio = gr.Textbox(label="Prompts de Audio")
|
338 |
+
audio_output = gr.Audio(label="Audio Generado")
|
339 |
audio_button = gr.Button("Generar Audio")
|
340 |
+
audio_button.click(generate_musicgen_audio_from_redis, inputs=text_prompts_audio, outputs=audio_output)
|
341 |
|
342 |
gr.Markdown("## Transcripci贸n de Audio con Whisper")
|
343 |
with gr.Row():
|
344 |
+
audio_file = gr.Audio(type="filepath", label="Archivo de Audio")
|
345 |
transcription_output = gr.Textbox(label="Transcripci贸n")
|
346 |
audio_button = gr.Button("Transcribir Audio")
|
347 |
+
audio_button.click(transcribe_audio_from_redis, inputs=audio_file, outputs=transcription_output)
|
348 |
|
349 |
gr.Markdown("## Traducci贸n de Texto")
|
350 |
with gr.Row():
|
|
|
353 |
src_lang_input = gr.Textbox(label="Idioma de Origen", value="en")
|
354 |
tgt_lang_input = gr.Textbox(label="Idioma de Destino", value="es")
|
355 |
translate_button = gr.Button("Traducir Texto")
|
356 |
+
translate_button.click(translate_text_from_redis, inputs=[text_input, src_lang_input, tgt_lang_input], outputs=translation_output)
|
357 |
|
358 |
gr.Markdown("## Resumen de Texto")
|
359 |
with gr.Row():
|
360 |
text_to_summarize = gr.Textbox(label="Texto para Resumir")
|
361 |
summary_output = gr.Textbox(label="Resumen")
|
362 |
summarize_button = gr.Button("Generar Resumen")
|
363 |
+
summarize_button.click(summarize_text_from_redis, inputs=text_to_summarize, outputs=summary_output)
|
364 |
|
365 |
app.launch()
|
366 |
|
367 |
if __name__ == "__main__":
|
368 |
+
gradio_app()
|