Spaces:
Sleeping
Sleeping
| from typing import List | |
| import torch | |
| import gradio as gr | |
| import spaces | |
| from sentence_transformers import SentenceTransformer | |
| device = torch.device("cpu") | |
| model = SentenceTransformer("Snowflake/snowflake-arctic-embed-l", device=device, trust_remote_code=True) | |
| def embed(document: str): | |
| return model.encode(document) | |
| with gr.Blocks() as app: | |
| # Create an input text box | |
| text_input = gr.Textbox(label="Enter text to embed") | |
| # Create an output component to display the embedding | |
| output = gr.JSON(label="Text Embedding") | |
| # When the input text is submitted, call the embedding function and display the output | |
| text_input.submit(embed, inputs=text_input, outputs=output) | |
| if __name__ == '__main__': | |
| app.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860) | |