Arnesh27 commited on
Commit
c41c45a
·
verified ·
1 Parent(s): 7c66f89

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load model and tokenizer
5
+ model = AutoModelForCausalLM.from_pretrained("HuggingFaceH4/starchat2-15b-v0.1")
6
+ tokenizer = AutoTokenizer.from_pretrained("HuggingFaceH4/starchat2-15b-v0.1")
7
+
8
+ # Function for inference
9
+ def generate_text(input_text):
10
+ inputs = tokenizer(input_text, return_tensors="pt")
11
+ outputs = model.generate(**inputs)
12
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
13
+
14
+ # Gradio interface
15
+ iface = gr.Interface(
16
+ fn=generate_text,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="Project Build",
20
+ description="Generate text using the StarChat model."
21
+ )
22
+
23
+ # Launch the app
24
+ iface.launch()