Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from functools import lru_cache
|
| 3 |
-
import openai # 用于调用外部API
|
| 4 |
import os
|
| 5 |
import spaces
|
| 6 |
import gradio as gr
|
| 7 |
from transformers import AutoTokenizer, AutoModel,AutoModelForCausalLM
|
| 8 |
-
import platform
|
| 9 |
import torch
|
| 10 |
-
import nltk
|
| 11 |
-
from functools import lru_cache
|
| 12 |
|
| 13 |
# 假设openai_client已定义,例如:
|
| 14 |
|
| 15 |
device = "cuda"
|
| 16 |
MODEL_NAME = "ByteDance-Seed/Seed-X-PPO-7B"
|
| 17 |
|
|
|
|
| 18 |
def load_model():
|
| 19 |
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME,torch_dtype="bfloat16").to(device)
|
| 20 |
print(f"Model loaded in {device}")
|
|
@@ -22,7 +19,7 @@ def load_model():
|
|
| 22 |
|
| 23 |
|
| 24 |
model = load_model()
|
| 25 |
-
|
| 26 |
# Loading the tokenizer once, because re-loading it takes about 1.5 seconds each time
|
| 27 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 28 |
|
|
@@ -88,4 +85,6 @@ with gr.Blocks() as demo:
|
|
| 88 |
outputs=output,
|
| 89 |
)
|
| 90 |
examples = gr.Examples(examples=examples_inputs,inputs=[input_text], fn=translate, outputs=output, cache_examples=True)
|
|
|
|
|
|
|
| 91 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from functools import lru_cache
|
|
|
|
| 3 |
import os
|
| 4 |
import spaces
|
| 5 |
import gradio as gr
|
| 6 |
from transformers import AutoTokenizer, AutoModel,AutoModelForCausalLM
|
|
|
|
| 7 |
import torch
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# 假设openai_client已定义,例如:
|
| 10 |
|
| 11 |
device = "cuda"
|
| 12 |
MODEL_NAME = "ByteDance-Seed/Seed-X-PPO-7B"
|
| 13 |
|
| 14 |
+
print("Start dowload")
|
| 15 |
def load_model():
|
| 16 |
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME,torch_dtype="bfloat16").to(device)
|
| 17 |
print(f"Model loaded in {device}")
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
model = load_model()
|
| 22 |
+
print("Ednd dowload")
|
| 23 |
# Loading the tokenizer once, because re-loading it takes about 1.5 seconds each time
|
| 24 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 25 |
|
|
|
|
| 85 |
outputs=output,
|
| 86 |
)
|
| 87 |
examples = gr.Examples(examples=examples_inputs,inputs=[input_text], fn=translate, outputs=output, cache_examples=True)
|
| 88 |
+
|
| 89 |
+
print("Prepared")
|
| 90 |
demo.launch()
|