Kohaku-Blueleaf commited on
Commit
41acb2e
1 Parent(s): 061237a

zeroGPU try

Browse files
Files changed (2) hide show
  1. app.py +3 -0
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  from time import time_ns
3
 
 
4
  import gradio as gr
5
  import torch
6
  from huggingface_hub import Repository
@@ -14,6 +15,7 @@ from kgen.metainfo import SPECIAL, TARGET
14
  MODEL_PATH = "KBlueLeaf/DanTagGen"
15
 
16
 
 
17
  @torch.no_grad()
18
  def get_result(
19
  text_model: LlamaForCausalLM,
@@ -30,6 +32,7 @@ def get_result(
30
  escape_bracket: bool = False,
31
  temperature: float = 1.35,
32
  ):
 
33
  start = time_ns()
34
  print("=" * 50, "\n")
35
  # Use LLM to predict possible summary
 
1
  import os
2
  from time import time_ns
3
 
4
+ import spaces
5
  import gradio as gr
6
  import torch
7
  from huggingface_hub import Repository
 
15
  MODEL_PATH = "KBlueLeaf/DanTagGen"
16
 
17
 
18
+ @spaces.GPU
19
  @torch.no_grad()
20
  def get_result(
21
  text_model: LlamaForCausalLM,
 
32
  escape_bracket: bool = False,
33
  temperature: float = 1.35,
34
  ):
35
+ text_model.eval().half().cuda()
36
  start = time_ns()
37
  print("=" * 50, "\n")
38
  # Use LLM to predict possible summary
requirements.txt CHANGED
@@ -3,4 +3,5 @@ transformers
3
  llama-cpp-python
4
  gradio
5
  requests
6
- sentencepiece
 
 
3
  llama-cpp-python
4
  gradio
5
  requests
6
+ sentencepiece
7
+ spaces