Spaces:
Build error
Build error
Create Gradio
Browse files
Gradio
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# 模型 API 端點 (替換成你選擇的模型 URL)
|
| 5 |
+
API_URL = "https://huggingface.co/KappaNeuro/ukiyo-e-art"
|
| 6 |
+
headers = {"Authorization": "Bearer YOUR_HUGGINGFACE_API_TOKEN"} # 你需要你的 Hugging Face API token
|
| 7 |
+
|
| 8 |
+
def query(payload):
|
| 9 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 10 |
+
return response.json()
|
| 11 |
+
|
| 12 |
+
def inference(text):
|
| 13 |
+
output = query({"inputs": text})
|
| 14 |
+
return output
|
| 15 |
+
|
| 16 |
+
# 創建 Gradio 介面
|
| 17 |
+
interface = gr.Interface(
|
| 18 |
+
fn=inference,
|
| 19 |
+
inputs=gr.Textbox(lines=2, placeholder="輸入文字..."),
|
| 20 |
+
outputs="text",
|
| 21 |
+
title="最棒第一組模型呼叫",
|
| 22 |
+
description="這是一個簡單的應用,用於呼叫 Hugging Face 模型"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
interface.launch()
|