hyejoo commited on
Commit
a7612db
1 Parent(s): 92343ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1,5 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
- # Use a pipeline as a high-level helper
3
  from transformers import pipeline
4
 
5
  pipe = pipeline("text2text-generation", model="yeye776/t5-OndeviceAI-HomeIoT")
 
1
+ # import torch
2
+ # from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ # import gradio as gr
4
+
5
+ # # Load model and tokenizer (using CPU for broader accessibility)
6
+ # model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype=torch.float32, device_map="cpu", trust_remote_code=True)
7
+ # tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)
8
+
9
+ # def generate_text(prompt):
10
+ # inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)
11
+ # outputs = model.generate(**inputs, max_length=200)
12
+ # text = tokenizer.batch_decode(outputs)[0]
13
+ # return text
14
+
15
+ # # Create Gradio interface
16
+ # iface = gr.Interface(
17
+ # fn=generate_text,
18
+ # inputs=[gr.Textbox(lines=5, label="Enter your prompt")],
19
+ # outputs="text",
20
+ # title="PHI-2 Text Generator",
21
+ # description="Generate text using the PHI-2 generative language model",
22
+ # )
23
+
24
+ # # Launch the interface
25
+ # iface.launch()
26
+
27
  import gradio as gr
 
28
  from transformers import pipeline
29
 
30
  pipe = pipeline("text2text-generation", model="yeye776/t5-OndeviceAI-HomeIoT")