bkoz commited on
Commit
095ce1b
β€’
1 Parent(s): 054b31a

added model download

Browse files
Files changed (2) hide show
  1. app.py +9 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import spaces
3
  import torch
 
4
 
5
  zero = torch.Tensor([0]).cuda()
6
  print(zero.device) # <-- 'cpu' πŸ€”
@@ -10,6 +11,13 @@ def greet(n):
10
  print(zero.device) # <-- 'cuda:0' πŸ€—
11
  return f"Hello {zero + n} Tensor"
12
 
 
 
 
 
 
 
 
13
  def load_model():
14
  from llama_cpp import Llama, LlamaGrammar
15
  model_url="https://huggingface.co/TheBloke/Llama-2-7B-GGUF/resolve/main/llama-2-7b.Q5_K_S.gguf"
@@ -48,7 +56,7 @@ def load_model():
48
  print(output['choices'][0]['text'])
49
  print()
50
 
51
-
52
  load_model()
53
  demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
54
  demo.launch(share=False)
 
1
  import gradio as gr
2
  import spaces
3
  import torch
4
+ from huggingface_hub import hf_hub_download
5
 
6
  zero = torch.Tensor([0]).cuda()
7
  print(zero.device) # <-- 'cpu' πŸ€”
 
11
  print(zero.device) # <-- 'cuda:0' πŸ€—
12
  return f"Hello {zero + n} Tensor"
13
 
14
+ def download_model():
15
+
16
+ REPO_ID = "TheBloke/Llama-2-7B-GGUF"
17
+ FILENAME = "llama-2-7b.Q5_K_S.gguf"
18
+
19
+ hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
20
+
21
  def load_model():
22
  from llama_cpp import Llama, LlamaGrammar
23
  model_url="https://huggingface.co/TheBloke/Llama-2-7B-GGUF/resolve/main/llama-2-7b.Q5_K_S.gguf"
 
56
  print(output['choices'][0]['text'])
57
  print()
58
 
59
+ download_model()
60
  load_model()
61
  demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
62
  demo.launch(share=False)
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- llama-cpp-python
 
 
1
+ llama-cpp-python
2
+ gradio