Sshubam commited on
Commit
b9f8a9e
·
verified ·
1 Parent(s): e02e623

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import torch
2
- import spaces
3
  from collections.abc import Iterator
4
  from threading import Thread
5
  import gradio as gr
@@ -20,7 +20,7 @@ DESCRIPTION = """\
20
 
21
  # if torch.cuda.is_available():
22
  model_id = "ai4bharat/IndicTrans3-beta"
23
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
24
  tokenizer = AutoTokenizer.from_pretrained(model_id)
25
 
26
 
@@ -49,9 +49,6 @@ LANGUAGES = {
49
  }
50
 
51
 
52
- # def translate(src_lang, text, tgt_lang):
53
-
54
- # return "Translation output will appear here..."
55
 
56
  @spaces.GPU
57
  def generate(
@@ -93,7 +90,6 @@ def generate(
93
  outputs.append(text)
94
  yield "".join(outputs)
95
 
96
-
97
  def store_feedback(rating, feedback_text):
98
  if not rating:
99
  gr.Warning("Please select a rating before submitting feedback.", duration=5)
@@ -123,7 +119,7 @@ with gr.Blocks(theme=gr.themes.Default(), css=css) as demo:
123
 
124
  text_input = gr.Textbox(
125
  placeholder="Enter text to translate...",
126
- label="",
127
  lines=10,
128
  max_lines=100,
129
  elem_id="input-text"
@@ -206,4 +202,4 @@ with gr.Blocks(theme=gr.themes.Default(), css=css) as demo:
206
  outputs=feedback_result
207
  )
208
 
209
- demo.launch()
 
1
  import torch
2
+ # import spaces
3
  from collections.abc import Iterator
4
  from threading import Thread
5
  import gradio as gr
 
20
 
21
  # if torch.cuda.is_available():
22
  model_id = "ai4bharat/IndicTrans3-beta"
23
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto", offload_folder="offload")
24
  tokenizer = AutoTokenizer.from_pretrained(model_id)
25
 
26
 
 
49
  }
50
 
51
 
 
 
 
52
 
53
  @spaces.GPU
54
  def generate(
 
90
  outputs.append(text)
91
  yield "".join(outputs)
92
 
 
93
  def store_feedback(rating, feedback_text):
94
  if not rating:
95
  gr.Warning("Please select a rating before submitting feedback.", duration=5)
 
119
 
120
  text_input = gr.Textbox(
121
  placeholder="Enter text to translate...",
122
+ label="Input text",
123
  lines=10,
124
  max_lines=100,
125
  elem_id="input-text"
 
202
  outputs=feedback_result
203
  )
204
 
205
+ demo.launch()