Spaces:
Running
Running
feat: pipeline方式
Browse files
app.py
CHANGED
@@ -1,4 +1,16 @@
|
|
1 |
import spaces
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|