Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,26 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from model import DecoderTransformer
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
vocab_size=33
|
| 8 |
+
n_embed=384
|
| 9 |
+
context_size=256
|
| 10 |
+
n_layer=6
|
| 11 |
+
n_head=6
|
| 12 |
+
dropout=0.2
|
| 13 |
+
|
| 14 |
+
model_id = "philipp-zettl/chessPT"
|
| 15 |
+
|
| 16 |
+
model_path = hf_hub_download(repo_id=model_id, filename="chessPT.pkl")
|
| 17 |
+
|
| 18 |
+
model = DecoderTransformer(vocab_size, n_embed, context_size, n_layer, n_head, dropout)
|
| 19 |
+
model.load_state_dict(torch.load(model_path))
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def greet(prompt):
|
| 23 |
+
return model.generate(prompt)
|
| 24 |
|
| 25 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 26 |
demo.launch()
|