Instructions to use decula/sd with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use decula/sd with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-9B") model = PeftModel.from_pretrained(base_model, "decula/sd") - Transformers
How to use decula/sd with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="decula/sd")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("decula/sd", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use decula/sd with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "decula/sd" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "decula/sd", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/decula/sd
- SGLang
How to use decula/sd 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 "decula/sd" \ --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": "decula/sd", "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 "decula/sd" \ --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": "decula/sd", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use decula/sd with Docker Model Runner:
docker model run hf.co/decula/sd
| import tweepy | |
| import datetime | |
| import os | |
| def get_tweets_from_user_list_v2(user_list, client, tweets_per_user=10): | |
| """ | |
| Retrieves the latest tweets from a list of Twitter users within the last 24 hours using Tweepy API v2. | |
| Args: | |
| user_list (list): A list of Twitter usernames (strings). | |
| client (tweepy.Client): An authenticated Tweepy Client object. | |
| tweets_per_user (int): The maximum number of tweets to retrieve per user. | |
| Returns: | |
| list: A list of tweet objects (dict) that are within the last 24 hours. The structure of the tweet objects is different in v2. | |
| Returns an empty list if there are errors. | |
| """ | |
| all_tweets = [] | |
| now = datetime.datetime.now(datetime.timezone.utc) # Important: Use UTC for consistency | |
| yesterday = now - datetime.timedelta(days=1) | |
| for username in user_list: | |
| try: | |
| # Get the user ID from the username | |
| user = client.get_user(username=username) | |
| if user.errors: | |
| print(f"Error getting user ID for {username}: {user.errors}") | |
| continue # Skip to the next user | |
| user_id = user.data['id'] | |
| # Fetch tweets from the user's timeline | |
| response = client.get_users_tweets( | |
| id=user_id, | |
| max_results=tweets_per_user, | |
| tweet_fields=["created_at", "text"], # Specify the fields you need | |
| ) | |
| if response.errors: | |
| print(f"Error fetching tweets for {username} (ID: {user_id}): {response.errors}") | |
| continue # Skip to the next user | |
| tweets = response.data | |
| if tweets: | |
| for tweet in tweets: | |
| tweet_time = tweet['created_at'] | |
| if tweet_time >= yesterday: | |
| all_tweets.append(tweet) | |
| else: | |
| break # Optimization: Stop searching for this user | |
| except Exception as e: # Catch any other unexpected errors | |
| print(f"Unexpected error fetching tweets for {username}: {e}") | |
| continue | |
| return all_tweets | |
| def authenticate_v2(): | |
| """Authenticates with the Twitter API v2 using a Bearer Token. | |
| Returns: | |
| tweepy.Client: An authenticated Tweepy Client object, or None if authentication fails. | |
| """ | |
| bearer_token = (f"AAAAAAAAAAAAAAAAAAAAAKmVzAEAAAAAhVM%2BPoJytUvDoQ%2FgIGfLdJXdocU%3DvS5ZF10O60kLJcY6MGiErCDHV7awcUKB75QqWpIlKh84rK5CFw") # Get the Bearer Token from env | |
| if not bearer_token: | |
| print("Error: Missing Twitter Bearer Token. Please set the environment variable.") | |
| return None | |
| try: | |
| client = tweepy.Client(bearer_token) | |
| # No direct "verify_credentials" in v2. You can try a simple API call to check. | |
| user = client.get_me() | |
| if user.errors: | |
| print(f"Authentication check failed: {user.errors}") | |
| return None | |
| print("Authentication successful (API v2)!") | |
| return client | |
| except Exception as e: | |
| print(f"Authentication failed (API v2): {e}") | |
| return None | |
| if __name__ == '__main__': | |
| # Authenticate with the Twitter API v2 | |
| client = authenticate_v2() | |
| if client is None: | |
| print("Exiting due to authentication failure.") | |
| exit() | |
| # Example Usage: | |
| user_list = ["dacefupan","aiwangupiao"] | |
| tweets = get_tweets_from_user_list_v2(user_list, client, tweets_per_user=5) | |
| if tweets: | |
| print(f"Found {len(tweets)} tweets from the last 24 hours:") | |
| for tweet in tweets: | |
| print(f"Text: {tweet['text']}\n") # Access tweet text | |
| print(f"Tweeted at: {tweet['created_at']}\n") #Access tweet created at time | |
| else: | |
| print("No tweets found in the last 24 hours or an error occurred.") |