Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# gradio_client ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ ๊ฐ์ | |
# ์ด๋ฏธ์ง ์ธ์ ํ์ดํ๋ผ์ธ ๋ก๋ | |
image_model = pipeline("image-classification", model="google/vit-base-patch16-224") | |
def generate_voice(prompt): | |
# Tango API๋ฅผ ์ฌ์ฉํ์ฌ ์์ฑ ์์ฑ (๊ฐ์ ) | |
return "https://example.com/generated_voice.mp3" # ์์ ์์ฑ ํ์ผ URL ๋ฐํ | |
def classify_and_generate_voice(uploaded_image): | |
# ์ด๋ฏธ์ง ๋ถ๋ฅ | |
predictions = image_model(uploaded_image) | |
top_prediction = predictions[0]['label'] | |
# ์์ฑ ์์ฑ | |
voice_result = generate_voice(top_prediction) | |
return top_prediction, voice_result | |
# Gradio ์ธํฐํ์ด์ค ์์ฑ ๋ฐ ์์ ์ด๋ฏธ์ง ์ค์ | |
iface = gr.Interface( | |
fn=classify_and_generate_voice, | |
inputs=gr.Image(type="pil"), | |
outputs=[gr.Label(), gr.Audio()], | |
examples=[["dog.jpg"]], # ์์ ์ด๋ฏธ์ง ๊ฒฝ๋ก๋ฅผ ๋ฆฌ์คํธ๋ก ์ถ๊ฐ | |
title="์ด๋ฏธ์ง ๋ถ๋ฅ ๋ฐ ์์ฑ ์์ฑ", | |
description="์ด๋ฏธ์ง๋ฅผ ์ ๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ํด๋นํ๋ ์์ฑ์ ์์ฑํฉ๋๋ค." | |
) | |
# ์ธํฐํ์ด์ค ์คํ | |
if __name__ == "__main__": | |
iface.launch(share=True) | |