Spaces:
Build error
Build error
Commit
Β·
93dc552
1
Parent(s):
dacec36
add vdf lib
Browse files
app.py
CHANGED
|
@@ -1,14 +1,52 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
import torch
|
|
|
|
| 4 |
|
| 5 |
zero = torch.Tensor([0]).cuda()
|
| 6 |
-
print(zero.device)
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
def greet(n):
|
| 10 |
-
print(zero.device)
|
| 11 |
return f"Hello {zero + n} Tensor"
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
+
import vdf_io
|
| 5 |
|
| 6 |
zero = torch.Tensor([0]).cuda()
|
| 7 |
+
print(zero.device) # <-- 'cpu' π€
|
| 8 |
+
|
| 9 |
+
print(vdf_io.__version__)
|
| 10 |
+
|
| 11 |
|
| 12 |
@spaces.GPU
|
| 13 |
def greet(n):
|
| 14 |
+
print(zero.device) # <-- 'cuda:0' π€
|
| 15 |
return f"Hello {zero + n} Tensor"
|
| 16 |
|
| 17 |
+
|
| 18 |
+
def reembed_dataset():
|
| 19 |
+
import datasets
|
| 20 |
+
# model
|
| 21 |
+
# embeddings = model.embed(ds)
|
| 22 |
+
# new_embeddings = model.reembed(embeddings)
|
| 23 |
+
|
| 24 |
+
# datasets.save_dataset(new_embeddings)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def reembed_main():
|
| 28 |
+
download_dataset()
|
| 29 |
+
reembed_dataset()
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def download_dataset():
|
| 33 |
+
import datasets
|
| 34 |
+
|
| 35 |
+
# ds = datasets.load_dataset()
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
demo = gr.Interface(
|
| 39 |
+
fn=reembed_main,
|
| 40 |
+
inputs=[
|
| 41 |
+
# dataset name
|
| 42 |
+
gr.inputs.Textbox(label="Dataset name"),
|
| 43 |
+
# embedding model
|
| 44 |
+
gr.inputs.Textbox(label="Embedding model"),
|
| 45 |
+
# output username
|
| 46 |
+
gr.inputs.Textbox(label="Output username"),
|
| 47 |
+
],
|
| 48 |
+
outputs=gr.outputs.Textbox(label="Output"),
|
| 49 |
+
title="Re-Embedder",
|
| 50 |
+
description="Re-embed a dataset using a given model and output to a new username's account",
|
| 51 |
+
)
|
| 52 |
demo.launch()
|