hacer201145 commited on
Commit
4e9d11a
·
verified ·
1 Parent(s): e00f261

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -1,4 +1,15 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
2
  with gr.Blocks() as demo:
3
- gr.Interface.load("huggingface", "hacer201145/Hasex0.1-355M")
4
- demo.launch()
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ model_name = "hacer201145/Hasex0.1-355M"
4
+ model = AutoModelForCausalLM.from_pretrained(model_name)
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ def generate_response(prompt):
7
+ inputs = tokenizer(prompt, return_tensors="pt")
8
+ output = model.generate(inputs["input_ids"], max_length=150)
9
+ return tokenizer.decode(output[0], skip_special_tokens=True)
10
  with gr.Blocks() as demo:
11
+ with gr.Row():
12
+ model_input = gr.Textbox(label="Enter your prompt", placeholder="Type something...")
13
+ model_output = gr.Textbox(label="Generated response")
14
+ model_input.submit(generate_response, inputs=model_input, outputs=model_output)
15
+ demo.launch()