Spaces:
Runtime error
Runtime error
File size: 1,184 Bytes
2bd9468 e57e37e 2bd9468 9902a40 8770d52 2bd9468 3377e03 e57e37e 87c119f 3377e03 8770d52 e57e37e 3377e03 2bd9468 e57e37e 23708c8 3377e03 23708c8 8770d52 e57e37e 3377e03 23708c8 2bd9468 3382a71 1defd08 e57e37e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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)
|