Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
import spaces
|
4 |
+
|
5 |
+
# SakanaAIのテキスト生成モデルの初期化
|
6 |
+
text_generator = pipeline("text-generation", model="SakanaAI/your-model-name")
|
7 |
+
|
8 |
+
# GPUを使用する関数の定義
|
9 |
+
@spaces.GPU
|
10 |
+
def generate_text(prompt):
|
11 |
+
result = text_generator(prompt, max_length=50)[0]
|
12 |
+
return result['generated_text']
|
13 |
+
|
14 |
+
# Gradioインターフェースの設定
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=generate_text,
|
17 |
+
inputs="text",
|
18 |
+
outputs="text",
|
19 |
+
title="SakanaAI テキスト生成",
|
20 |
+
description="プロンプトを入力して、テキストを生成します。"
|
21 |
+
)
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
iface.launch()
|