Merlintxu commited on
Commit
cadb09a
·
1 Parent(s): c34ea7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from transformers import pipeline
2
  from gradio import Interface
3
  import gradio as gr
@@ -14,7 +15,7 @@ MODELS = {
14
  def generate_and_analyze(model_name, input_text):
15
  # Load the model from the dictionary using the selected model name
16
  model = MODELS[model_name]
17
- text_generator = pipeline('text-generation', model=model)
18
  result = text_generator(input_text, max_length=250, do_sample=True)[0]
19
  return result['generated_text']
20
 
@@ -28,3 +29,4 @@ iface = gr.Interface(
28
  outputs="text"
29
  )
30
  iface.launch()
 
 
1
+ ## app.py ##
2
  from transformers import pipeline
3
  from gradio import Interface
4
  import gradio as gr
 
15
  def generate_and_analyze(model_name, input_text):
16
  # Load the model from the dictionary using the selected model name
17
  model = MODELS[model_name]
18
+ text_generator = pipeline('text-generation', model=model, device=0) # Use GPU if available
19
  result = text_generator(input_text, max_length=250, do_sample=True)[0]
20
  return result['generated_text']
21
 
 
29
  outputs="text"
30
  )
31
  iface.launch()
32
+