Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 5,786 Bytes
5acd9c3 59e0f6a 5acd9c3 59e0f6a 5acd9c3 59e0f6a 5acd9c3 59e0f6a 5acd9c3 83f2577 5acd9c3 83f2577 5acd9c3 83f2577 5acd9c3 83f2577 5acd9c3 83f2577 5acd9c3 83f2577 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
import os
PRODUCT_NAME = os.environ.get('PRODUCT_NAME', 'AiTube')
PRODUCT_VERSION = "2.0.0"
TEXT_MODEL = os.environ.get('HF_TEXT_MODEL',
#'HuggingFaceH4/zephyr-7b-beta'
'HuggingFaceTB/SmolLM2-1.7B-Instruct'
)
IMAGE_MODEL = os.environ.get('HF_IMAGE_MODEL', '')
# Environment variable to control maintenance mode
MAINTENANCE_MODE = os.environ.get('MAINTENANCE_MODE', 'false').lower() in ('true', 'yes', '1', 't')
# Environment variable to control how many nodes to use
MAX_NODES = int(os.environ.get('MAX_NODES', '8'))
ADMIN_ACCOUNTS = [
"jbilcke-hf"
]
RAW_VIDEO_ROUND_ROBIN_ENDPOINT_URLS = [
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_1', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_2', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_3', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_4', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_5', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_6', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_7', ''),
os.environ.get('VIDEO_ROUND_ROBIN_SERVER_8', ''),
]
# Filter out empty strings from the endpoint list
filtered_urls = [url for url in RAW_VIDEO_ROUND_ROBIN_ENDPOINT_URLS if url]
# Limit the number of URLs based on MAX_NODES environment variable
VIDEO_ROUND_ROBIN_ENDPOINT_URLS = filtered_urls[:MAX_NODES]
HF_TOKEN = os.environ.get('HF_TOKEN')
# use the same secret token as you used to secure your BASE_SPACE_NAME spaces
SECRET_TOKEN = os.environ.get('SECRET_TOKEN')
# altenative words we could use: "saturated, highlight, overexposed, highlighted, overlit, shaking, too bright, worst quality, inconsistent motion, blurry, jittery, distorted, cropped, watermarked, watermark, logo, subtitle, subtitles, lowres"
NEGATIVE_PROMPT = "low quality, worst quality, deformed, distorted, disfigured, blurry, text, watermark"
POSITIVE_PROMPT_SUFFIX = "high quality, cinematic, 4K, intricate details"
GUIDANCE_SCALE = 1.0
# anonymous users are people browing AiTube2 without being connected
# this category suffers from regular abuse so we need to enforce strict limitations
CONFIG_FOR_ANONYMOUS_USERS = {
# anons can only watch 2 minutes per video
"max_rendering_time_per_client_per_video_in_sec": 2 * 60,
"max_buffer_size": 2,
"max_concurrent_generations": 2,
"min_num_inference_steps": 2,
"default_num_inference_steps": 3,
"max_num_inference_steps": 4,
"min_num_frames": 9, # 8 + 1
"default_max_num_frames": 65, # 8*8 + 1
"max_num_frames": 65, # 8*8 + 1
"min_clip_duration_seconds": 1,
"default_clip_duration_seconds": 2,
"max_clip_duration_seconds": 2,
"min_clip_playback_speed": 0.7,
"default_clip_playback_speed": 0.7,
"max_clip_playback_speed": 0.7,
"min_clip_framerate": 8,
"default_clip_framerate": 16,
"max_clip_framerate": 16,
"min_clip_width": 544,
"default_clip_width": 544,
"max_clip_width": 544,
"min_clip_height": 320,
"default_clip_height": 320,
"max_clip_height": 320,
}
# Hugging Face users enjoy a more normal and calibrated experience
CONFIG_FOR_STANDARD_HF_USERS = {
"max_rendering_time_per_client_per_video_in_sec": 15 * 60,
"max_buffer_size": 2,
"max_concurrent_generations": 2,
"min_num_inference_steps": 2,
"default_num_inference_steps": 4,
"max_num_inference_steps": 6,
"min_num_frames": 9, # 8 + 1
"default_num_frames": 65, # 8*8 + 1
"max_num_frames": 65, # 8*8 + 1
"min_clip_duration_seconds": 1,
"default_clip_duration_seconds": 2,
"max_clip_duration_seconds": 2,
"min_clip_playback_speed": 0.7,
"default_clip_playback_speed": 0.8,
"max_clip_playback_speed": 0.8,
"min_clip_framerate": 8,
"default_clip_framerate": 25,
"max_clip_framerate": 25,
"min_clip_width": 544,
"default_clip_width": 640,
"max_clip_width": 640,
"min_clip_height": 320,
"default_clip_height": 416,
"max_clip_height": 416,
}
# Hugging Face users with a Pro may enjoy an improved experience
CONFIG_FOR_PRO_HF_USERS = {
"max_rendering_time_per_client_per_video_in_sec": 20 * 60,
"max_buffer_size": 2,
"max_concurrent_generations": 2,
"min_num_inference_steps": 2,
"max_num_inference_steps": 8,
"min_num_frames": 9, # 8 + 1
"default_num_frames": 97, # (8*12) + 1
"max_num_frames": 97, # (8*12) + 1
"min_clip_duration_seconds": 1,
"default_clip_duration_seconds": 2,
"max_clip_duration_seconds": 3,
"min_clip_playback_speed": 0.7,
"default_clip_playback_speed": 0.8,
"max_clip_playback_speed": 0.8,
"min_clip_framerate": 8,
"default_clip_framerate": 25,
"max_clip_framerate": 30,
"min_clip_width": 544,
"default_clip_width": 768,
"max_clip_width": 768,
"min_clip_height": 320,
"default_clip_height": 480,
"max_clip_height": 480,
}
CONFIG_FOR_ADMIN_HF_USERS = {
"max_rendering_time_per_client_per_video_in_sec": 60 * 60,
"max_buffer_size": 2,
"max_concurrent_generations": 2,
"min_num_inference_steps": 2,
"default_num_inference_steps": 4,
"max_num_inference_steps": 8,
"min_num_frames": 9, # 8 + 1
"default_num_frames": 65, # (8 * 8) + 1
"max_num_frames": 129, # (8 * 16) + 1
"min_clip_duration_seconds": 1,
"default_clip_duration_seconds": 2,
"max_clip_duration_seconds": 4,
"min_clip_playback_speed": 0.7,
"default_clip_playback_speed": 0.8,
"max_clip_playback_speed": 0.9,
"min_clip_framerate": 8,
"default_clip_framerate": 30,
"max_clip_framerate": 60,
"min_clip_width": 544,
"default_clip_width": 768,
"max_clip_width": 1216,
"min_clip_height": 320,
"default_clip_height": 480,
"max_clip_height": 704,
}
CONFIG_FOR_ANONYMOUS_USERS = CONFIG_FOR_STANDARD_HF_USERS |