Sergidev commited on
Commit
8bd6e7a
Β·
verified Β·
1 Parent(s): 19a5ad7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -3,7 +3,6 @@ from threading import Thread
3
  from typing import Iterator
4
 
5
  import gradio as gr
6
- import spaces
7
  import torch
8
  from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
9
  DESCRIPTION = """\
@@ -14,6 +13,8 @@ This is a demo of [`Qwen/Qwen2-0.5B-Instruct`](https://huggingface.co/Qwen/Qwen2
14
  This space allows you to input text and have the AI complete it. Simply type your text in the input box, click "Complete", and watch as the AI generates a continuation of your text.
15
 
16
  You can adjust various parameters such as temperature and top-p sampling to control the generation process.
 
 
17
  """
18
 
19
  MAX_MAX_NEW_TOKENS = 2048
@@ -30,7 +31,6 @@ model = AutoModelForCausalLM.from_pretrained(
30
  torch_dtype=torch.bfloat16,
31
  )
32
  model.eval()
33
- @spaces.GPU(duration=90)
34
  def generate(
35
  message: str,
36
  max_new_tokens: int = 1024,
@@ -64,7 +64,8 @@ def generate(
64
  for text in streamer:
65
  full_message += text
66
  yield full_message
67
- with gr.Blocks(css="style.css", fill_height=True) as demo:
 
68
  gr.Markdown(DESCRIPTION)
69
  gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
70
 
@@ -143,4 +144,7 @@ def generate(
143
  )
144
 
145
  if __name__ == "__main__":
 
 
 
146
  demo.queue(max_size=20).launch()
 
3
  from typing import Iterator
4
 
5
  import gradio as gr
 
6
  import torch
7
  from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
8
  DESCRIPTION = """\
 
13
  This space allows you to input text and have the AI complete it. Simply type your text in the input box, click "Complete", and watch as the AI generates a continuation of your text.
14
 
15
  You can adjust various parameters such as temperature and top-p sampling to control the generation process.
16
+
17
+ Note: You may see a warning about bitsandbytes being compiled without GPU support. This is expected in environments without GPU and does not affect the basic functionality of the demo.
18
  """
19
 
20
  MAX_MAX_NEW_TOKENS = 2048
 
31
  torch_dtype=torch.bfloat16,
32
  )
33
  model.eval()
 
34
  def generate(
35
  message: str,
36
  max_new_tokens: int = 1024,
 
64
  for text in streamer:
65
  full_message += text
66
  yield full_message
67
+
68
+ with gr.Blocks(css="style.css", fill_height=True) as demo:
69
  gr.Markdown(DESCRIPTION)
70
  gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
71
 
 
144
  )
145
 
146
  if __name__ == "__main__":
147
+
148
+ demo = gr.Blocks(css="style.css", fill_height=True)
149
+
150
  demo.queue(max_size=20).launch()