Instructions to use ryefoxlime/TADBot with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ryefoxlime/TADBot with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ryefoxlime/TADBot")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ryefoxlime/TADBot", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ryefoxlime/TADBot with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ryefoxlime/TADBot" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ryefoxlime/TADBot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ryefoxlime/TADBot
- SGLang
How to use ryefoxlime/TADBot with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ryefoxlime/TADBot" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ryefoxlime/TADBot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ryefoxlime/TADBot" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ryefoxlime/TADBot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ryefoxlime/TADBot with Docker Model Runner:
docker model run hf.co/ryefoxlime/TADBot
| import socket | |
| import os | |
| import torch | |
| from threading import Timer | |
| import pyttsx3 | |
| import speech_recognition as sr | |
| from detectfaces import fer | |
| from models.PosterV2_7cls import pyramid_trans_expr2 | |
| from main import RecorderMeter1, RecorderMeter # noqa: F401 | |
| import time | |
| script_dir = os.path.dirname(os.path.abspath(__file__)) | |
| # Construct the full path to the model file | |
| model_path = os.path.join(script_dir,"models","checkpoints","raf-db-model_best.pth") | |
| # Determine the available device for model execution | |
| if torch.backends.mps.is_available(): | |
| device = "mps" | |
| elif torch.cuda.is_available(): | |
| device = "cuda" | |
| else: | |
| device = "cpu" | |
| # Initialize the model with specified image size and number of classes | |
| model = pyramid_trans_expr2(img_size=224, num_classes=7) | |
| # Wrap the model with DataParallel for potential multi-GPU usage | |
| model = torch.nn.DataParallel(model) | |
| # Move the model to the chosen device | |
| model = model.to(device) | |
| fer(model_path=model_path, device=device, model=model) | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.bind(('', 5001)) | |
| s.listen(5) | |
| print("Bot is Running") | |
| def handle_client(clientsocket): | |
| r = sr.Recognizer() | |
| m = sr.Microphone() | |
| try: | |
| while True: | |
| prompt = '' | |
| print("Speak now:") | |
| sent = False | |
| with m as source: | |
| audio = r.listen(source) | |
| try: | |
| prompt = r.recognize_google(audio) | |
| print("Tadbot Thinks you said:", prompt) | |
| sent = True | |
| except sr.UnknownValueError: | |
| print("Tadbot could not understand audio. Try Again") | |
| except sr.RequestError as e: | |
| print(f"Could not request results from Google Speech Recognition service: {e}") | |
| if sent: | |
| print("please Wait!") | |
| try: | |
| clientsocket.send(bytes(prompt, 'utf-8')) | |
| response = clientsocket.recv(1024).decode("utf-8") | |
| engine = pyttsx3.init('espeak') | |
| voices = engine.getProperty('voices') | |
| engine.setProperty('voice', voices[26].id) | |
| engine.setProperty('rate', 145) | |
| engine.say(response) | |
| engine.runAndWait() | |
| print("TADBot:", response) | |
| except (socket.error, ConnectionResetError) as e: | |
| print(f"Connection error: {e}") | |
| break # Exit loop if connection breaks | |
| time.sleep(60) # Wait for 60 seconds before listening again | |
| finally: | |
| clientsocket.close() | |
| print("Connection Closed") | |
| while True: | |
| try: | |
| clientsocket, address = s.accept() | |
| print(f"Accepted connection from {address}") | |
| handle_client(clientsocket) #Handle each client in a separate function | |
| except KeyboardInterrupt: | |
| print("Server shutting down...") | |
| break | |
| except Exception as e: | |
| print(f"An error occurred: {e}") | |
| s.close() |