AlyxTeam commited on
Commit
0b2ff15
·
1 Parent(s): 19488e2

feat: pipeline方式

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -1,4 +1,16 @@
1
  import spaces
 
2
  import gradio as gr
3
 
4
- gr.load("models/jinaai/jina-embeddings-v2-base-code").launch()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import spaces
2
+ from transformers import pipeline
3
  import gradio as gr
4
 
5
+ pipe = pipeline("feature-extraction", model="jinaai/jina-embeddings-v2-base-code", trust_remote_code=True)
6
+ pipe.to('cuda')
7
+
8
+ @spaces.GPU
9
+ def generate(prompt):
10
+ return pipe(prompt)[0].numpy().mean(axis=0)
11
+
12
+ gr.Interface(
13
+ fn=generate,
14
+ inputs=gr.Text(),
15
+ outputs=gr.Gallery(),
16
+ ).launch()