Spaces:
Build error
Build error
Initial Space setup of broadfield-dev/my-ai-space3 via Builder
Browse files- app.py +31 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCTC, AutoTokenizer
|
3 |
+
from huggingface_hub import inference_client
|
4 |
+
from huggingface_hub.modelHub import ModelHubClient
|
5 |
+
|
6 |
+
model_hub_client = ModelHubClient()
|
7 |
+
inference_client = inference_client()
|
8 |
+
|
9 |
+
def chatbot(input_text):
|
10 |
+
# Load models
|
11 |
+
model_name = "your-model-name"
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
13 |
+
model = AutoModelForCTC.from_pretrained(model_name)
|
14 |
+
|
15 |
+
# Generate output
|
16 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
17 |
+
outputs = model(**inputs)
|
18 |
+
output_text = outputs.logits.argmax(-1)
|
19 |
+
|
20 |
+
# Return output
|
21 |
+
return output_text
|
22 |
+
|
23 |
+
demov2 = gr.Interface(
|
24 |
+
fn=chatbot,
|
25 |
+
inputs="text",
|
26 |
+
outputs="text",
|
27 |
+
title="My Chatbot",
|
28 |
+
description="A chatbot that uses Hugging Face models to respond to user input"
|
29 |
+
)
|
30 |
+
|
31 |
+
demov2.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
gradio
|
3 |
+
huggingface-inference-client
|