Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
185ada5
Validator Proxy Response Update (#103)
dylanuys Nov 20, 2024
132dc62
Two new image models: SDXL finetuned on Midjourney, and SD finetuned …
aliang322 Nov 20, 2024
7f8a26a
Added required StableDiffusionPipeline import
aliang322 Nov 20, 2024
ec35faf
Merge pull request #105 from BitMind-AI/expand-models/image-finetuned
aliang322 Nov 21, 2024
c98c08f
Updated transformers version to fix tokenizer initialization error
benliang99 Nov 22, 2024
b3d0a57
Merge pull request #107 from BitMind-AI/transformers-version-update
aliang322 Nov 22, 2024
f2cefdd
GPU Specification (#108)
dylanuys Nov 24, 2024
3097718
Update __init__.py
dylanuys Nov 24, 2024
686fbf7
pulling in latest from main
dylanuys Nov 24, 2024
6060c65
removing logging
benliang99 Nov 24, 2024
5c00f9e
old logging removed
benliang99 Nov 25, 2024
fe9fa6d
adding check for state file in case it is deleted somehow
dylanuys Nov 25, 2024
343b1d6
Merge branch 'testnet' of github.com:BitMind-AI/bitmind-subnet into t…
dylanuys Nov 25, 2024
14a32c3
removing remaining random prompt generation code
benliang99 Nov 25, 2024
a4032dc
Merge branch 'main' into testnet
dylanuys Nov 27, 2024
3866df2
Merge branch 'main' into testnet
dylanuys Dec 2, 2024
4678efa
[Testnet] Video Challenges V1 (#111)
dylanuys Dec 3, 2024
d35af29
fixing image_size for augmentations
dylanuys Dec 3, 2024
3e23a4a
Updated validator gpu requirements (#113)
benliang99 Dec 3, 2024
912c8ab
splitting rewards over image and video (#112)
dylanuys Dec 3, 2024
d22a250
Update README.md (#110)
kenobijon Dec 3, 2024
92dafa4
combining requirements files
dylanuys Dec 3, 2024
fe84b1a
Merge branch 'testnet' of github.com:BitMind-AI/bitmind-subnet into t…
dylanuys Dec 3, 2024
d46694c
Combined requirements installation
benliang99 Dec 3, 2024
3e5c2e2
Improved formatting, added checks to prevent overwriting existing .en…
benliang99 Dec 3, 2024
485f095
Merge pull request #115 from BitMind-AI/combined-requirements
aliang322 Dec 3, 2024
f3edacc
Re-added endpoint options
benliang99 Dec 3, 2024
80a0773
Fixed incorrect diffusers install
benliang99 Dec 4, 2024
f907031
Fixed missing initialization of miner performance trackers
benliang99 Dec 4, 2024
e115a52
Merge pull request #117 from BitMind-AI/video-uat-fixes
aliang322 Dec 4, 2024
0feab36
[Testnet] Docs Updates (#114)
dylanuys Dec 4, 2024
d7c4a1f
Removed deprecated requirements files from github tests (#118)
benliang99 Dec 4, 2024
00a591d
[Testnet] Async Cache Updates (#119)
dylanuys Dec 4, 2024
ae2904f
Increased minimum and recommended storage (#120)
benliang99 Dec 4, 2024
235c483
[Testnet] Data download cleanup (#121)
dylanuys Dec 4, 2024
43f8b71
pep8
dylanuys Dec 4, 2024
9c7e6b3
use png codec, sample by framerate + num frames
dylanuys Dec 4, 2024
979bc86
fps, min_fps, max_fps parameterization of sample
dylanuys Dec 4, 2024
9d5fbb2
return fps and num frames
dylanuys Dec 4, 2024
3add4a8
Merge pull request #122 from BitMind-AI/variable-framerate-sampling
aliang322 Dec 4, 2024
7870207
Fix registry module imports (#123)
dylanuys Dec 5, 2024
571c4c6
Update README.md
dylanuys Dec 5, 2024
0b455a3
README title
dylanuys Dec 5, 2024
ac9f495
removing samples from cache
dylanuys Dec 5, 2024
391b3af
README
dylanuys Dec 5, 2024
e9f47ce
fixing cache removal (#125)
dylanuys Dec 5, 2024
c5c7cde
Fixed tensor not being set to device for video challenges, causing er…
aliang322 Dec 5, 2024
fd5b640
Mainnet Prep (#127)
dylanuys Dec 5, 2024
36b3721
removign old reqs from autoupdate
dylanuys Dec 5, 2024
b772db0
Re-added bitmind HF org prefix to dataset path
benliang99 Dec 5, 2024
dbf1114
Merge pull request #128 from BitMind-AI/open-images-path-fix
aliang322 Dec 5, 2024
93fb6aa
shortening self heal timer
dylanuys Dec 5, 2024
5f849c6
autoupdate
dylanuys Dec 5, 2024
94d2eeb
autoupdate
dylanuys Dec 5, 2024
ec3a8f7
sample size
dylanuys Dec 5, 2024
1a07c68
pulling in hotfix from main
dylanuys Dec 6, 2024
5acb1af
Merge branch 'main' into testnet
dylanuys Dec 10, 2024
2416dbd
Validator Improvements: VRAM usage, logging (#131)
dylanuys Dec 11, 2024
c2cb1c5
version bump
dylanuys Dec 11, 2024
7e527ea
moved info log setting to config.py
dylanuys Dec 11, 2024
649e29a
Merge branch 'main' into testnet
dylanuys Dec 17, 2024
e47c49d
Bittensor 8.5.1 (#133)
dylanuys Dec 18, 2024
ef8e129
Prompt Generation Pipeline Improvements (#135)
dylanuys Jan 5, 2025
3507bad
[testnet] I2i/in painting (#137)
dylanuys Jan 7, 2025
eb73189
Updated image_annotation_generator to prompt_generator (#138)
aliang322 Jan 8, 2025
93e7fc9
bump version 2.0.3 -> 2.1.0
dylanuys Jan 8, 2025
ab0aac8
testing cache clearing via autoupdate
dylanuys Jan 8, 2025
49261cf
Merge branch 'testnet' of github.com:BitMind-AI/bitmind-subnet into t…
dylanuys Jan 8, 2025
7fda1bc
cranking up video rewards to .2
dylanuys Jan 8, 2025
47cfe4e
Merge branch 'main' into testnet
dylanuys Jan 8, 2025
dd30c8a
Add DeepFloyd/IF model and multi-stage pipeline support
aliang322 Jan 10, 2025
941b3ec
Moved multistage pipeline generator to SyntheticDataGenerator
aliang322 Jan 10, 2025
927e932
Args for testing specific model
aliang322 Jan 10, 2025
15e5ffe
[TESTNET] HunyuanVideo (#140)
dylanuys Jan 23, 2025
19850af
merging main
dylanuys Jan 23, 2025
aa88c87
Update __init__.py
dylanuys Jan 23, 2025
304f8f4
updated subnet arch diagram
dylanuys Jan 25, 2025
d9cec1e
README wip
dylanuys Jan 25, 2025
dc2ba6a
docs udpates
dylanuys Jan 25, 2025
10c6c55
README updates
dylanuys Jan 25, 2025
25bb436
README updates
dylanuys Jan 25, 2025
f6d6e0e
more README udpates
dylanuys Jan 25, 2025
da32df2
README updates
dylanuys Jan 25, 2025
3f94567
README udpates
dylanuys Jan 25, 2025
b7a9427
README cleanup
dylanuys Jan 25, 2025
c59e36b
more README updates
dylanuys Jan 25, 2025
bc82324
Fixing table border removal html for github
dylanuys Jan 25, 2025
6815dba
fixing table html
dylanuys Jan 25, 2025
a136012
one last attempt at a prettier table
dylanuys Jan 25, 2025
2c683e8
one last last attempt at a prettier table
dylanuys Jan 25, 2025
7a5d94c
bumping video rewards
dylanuys Jan 25, 2025
79cf10d
removing decay for unsampled miners
dylanuys Jan 26, 2025
6a03333
README cleanup
dylanuys Jan 26, 2025
a6e0ee9
increasing suggested and min compute for validators
dylanuys Jan 27, 2025
655bc2b
README update, markdown fix in Incentive.md
dylanuys Jan 27, 2025
4cb3bd6
README tweak
dylanuys Jan 27, 2025
d84b4cc
removing redundant dereg check from update_scores
dylanuys Jan 27, 2025
4550958
Deepfloyed specific configs, args for better cache/data gen testing, …
aliang322 Jan 28, 2025
ae11857
Merge testnet into t2i/deepfloyed-if
aliang322 Jan 28, 2025
4f24e5b
use largest deepfloyed-if I and II models, ensure no watermarker
aliang322 Jan 30, 2025
b930fbf
Fixed FLUX resolution format, added back model_id and scheduler loadi…
aliang322 Jan 30, 2025
5f7d139
Add Janus-Pro-7B t2i model with custom diffuser pipeline class
aliang322 Jan 30, 2025
7dbc0c7
Janus repo install
aliang322 Jan 30, 2025
bbceeca
Removed custom wrapper files, added Janus DiffusionPipeline wrapper t…
aliang322 Jan 30, 2025
4ac1a4e
Removed DiffusionPipeline import
aliang322 Jan 30, 2025
655e1f5
Uncomment wandb inits
aliang322 Jan 30, 2025
098a4b1
Move create_pipeline_generator() to model utils
aliang322 Feb 3, 2025
4dd1c79
Moved model optimizations to model utils
aliang322 Feb 3, 2025
1e0bbc3
Merge pull request #147 from BitMind-AI/t2i/deepfloyed-if-and-janus-pro
aliang322 Feb 3, 2025
c7a23dd
[Testnet] Mutli-Video Challenges (#148)
dylanuys Feb 6, 2025
5a64f22
merging main
dylanuys Feb 6, 2025
cbce647
Update config.py
dylanuys Feb 6, 2025
a7561fa
explicit requirements install
dylanuys Feb 6, 2025
f172cbb
moving pm2 process stopping prior to model verification
dylanuys Feb 7, 2025
6eb5352
fix for no available vidoes in multi-video challenge generation
dylanuys Feb 7, 2025
1ea4f7c
Update forward.py
dylanuys Feb 7, 2025
06cbe62
Merge branch 'main' into testnet
dylanuys Feb 11, 2025
913ee2a
[Testnet] Multiclass Rewards (#150)
dylanuys Feb 18, 2025
094e353
[Testnet] video organics (#151)
dylanuys Feb 19, 2025
aa3fb64
Validator Proxy handling of Multiclass Responses (#153)
dylanuys Feb 20, 2025
d343485
new incentive docs (#154)
dylanuys Feb 20, 2025
807ff35
python-multipart
dylanuys Feb 20, 2025
bf6a629
Merge branch 'main' into testnet
dylanuys Feb 20, 2025
ee11a95
merging main
dylanuys Feb 21, 2025
78635fe
Merge branch 'main' into testnet
dylanuys Feb 26, 2025
c54fbea
Semisynthetic Cache (#158)
dylanuys Mar 10, 2025
1b15ba9
version bump
dylanuys Mar 10, 2025
fcc686e
Changing mutliclass reward weight to .25
dylanuys Mar 10, 2025
b4414c6
uncommenting dlib
dylanuys Mar 10, 2025
36596dc
bittensor==9.0.3
dylanuys Mar 10, 2025
8059507
Handling datasets with few files that don't need regular local updates
dylanuys Mar 10, 2025
d382d55
fixing error logging variable names
dylanuys Mar 10, 2025
0a34dc3
merging main
dylanuys Mar 13, 2025
96b65c4
dreamshaper-8-inpainting (#161)
dylanuys Mar 13, 2025
c7ebe7b
Vali/sd v15 inpainting (#162)
dylanuys Mar 13, 2025
705794b
refresh cache
dylanuys Mar 17, 2025
5b9b820
Merge branch 'main' into testnet
dylanuys Mar 19, 2025
f9f1dbf
[Testnet] Broken Pipes Fix (#166)
dylanuys Mar 19, 2025
baf7a87
Added LORA model support
benliang99 Mar 24, 2025
b75f4b9
Added JourneyDB static synthetic dataset
benliang99 Mar 25, 2025
e987dd9
Added GenImage Midjourney synthetic image dataset
benliang99 Mar 25, 2025
7a42e1d
Fixed dataset name
benliang99 Mar 25, 2025
7087f2b
Added import for SYNTH_IMAGE_CACHE_DIR
benliang99 Mar 26, 2025
dc6a0d7
Typo
benliang99 Mar 26, 2025
e26fbbe
Merge branch 'main' into GenImage-MidJourney
benliang99 Mar 26, 2025
411d415
Merge pull request #171 from BitMind-AI/GenImage-MidJourney
benliang99 Mar 26, 2025
570c0d2
Merge branch 'main' into testnet
dylanuys Mar 28, 2025
7641212
merging scores fix to testnet
dylanuys Mar 28, 2025
deefe0e
Merge branch 'main' into testnet
dylanuys Mar 31, 2025
45af4af
fix for augmented video logging (#177)
dylanuys Mar 31, 2025
bf760f0
wanbd cleanup
dylanuys Apr 1, 2025
43e2637
logging update, testing autoupdate
dylanuys Apr 1, 2025
e72f406
making wandb cache clears periodic regardless of autoupdate/self heal
dylanuys Apr 1, 2025
6374cb0
move wandb cache cleaning to its own dir
dylanuys Apr 1, 2025
6e7e878
typo
dylanuys Apr 1, 2025
7ad9ede
bump version
dylanuys Apr 1, 2025
c4e941c
increasing min stake
dylanuys Apr 1, 2025
beeada4
Merge pull request #179 from BitMind-AI/miner/vpermit-tao-limit
benliang99 Apr 1, 2025
f4ed988
version bump
dylanuys Apr 1, 2025
9575ab0
merging main
dylanuys Apr 1, 2025
aef362d
typo
dylanuys Apr 1, 2025
3fae6cc
still no scores for blacklisted vaidators
dylanuys Apr 1, 2025
f3c2187
leaving vpermit_tao_limit as default and adding explicitly to blackli…
dylanuys Apr 1, 2025
6209d93
feat(i2v): add image-to-video generation support with motion-enhanced…
benliang99 Apr 10, 2025
a8e6b39
Updated name of mugshots dataset
benliang99 Apr 10, 2025
7be293c
Version bump
benliang99 Apr 10, 2025
4e4ad42
Merge branch 'testnet' into challenge-expansion
benliang99 Apr 11, 2025
839ea13
Adjusted i2v video dimensions
benliang99 Apr 11, 2025
87c8264
Adjusted num_frames to match CogVideoXImageToVideo source code default
benliang99 Apr 11, 2025
85cbddc
refactor(prompt): simplify video prompt enhancement rules
benliang99 Apr 11, 2025
51b33cf
missing import
dylanuys Apr 12, 2025
2104e71
removing generate_from_prompt
dylanuys Apr 12, 2025
3dd2b24
add i2v models to batch generation interleaving
benliang99 Apr 14, 2025
ddab61c
Removed I2V model
benliang99 Apr 14, 2025
02bcad0
fix: remove i2v from random task selection and add safety check
benliang99 Apr 14, 2025
d069138
Removed deprecated inpainting model and bumped diffusers version
benliang99 Apr 14, 2025
748c079
Revert stable-diffusion-v1-5/stable-diffusion-inpainting model removal
benliang99 Apr 14, 2025
0ed84b2
Re-removed deprecated inpainting model, fixed model verification debu…
benliang99 Apr 14, 2025
ab966be
Merge pull request #181 from BitMind-AI/challenge-expansion
benliang99 Apr 14, 2025
f5e0827
Removed generate_from_prompt function used for external dataset gener…
benliang99 Apr 14, 2025
f80ce41
Merge pull request #183 from BitMind-AI/challenge-expansion
benliang99 Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bitmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# DEALINGS IN THE SOFTWARE.


__version__ = "2.2.8"
__version__ = "2.2.9"
version_split = __version__.split(".")
__spec_version__ = (
(1000 * int(version_split[0]))
Expand Down
44 changes: 22 additions & 22 deletions bitmind/synthetic_data_generation/prompt_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def clear_gpu(self) -> None:
def generate(
self,
image: Image.Image,
task: Optional[str] = None,
max_new_tokens: int = 20,
verbose: bool = False
) -> str:
Expand All @@ -127,6 +128,8 @@ def generate(

Args:
image: The image for which the description is to be generated.
task: The generation task ('t2i', 't2v', 'i2i', 'i2v'). If video task,
motion descriptions will be added.
max_new_tokens: The maximum number of tokens to generate for each
prompt.
verbose: If True, additional logging information is printed.
Expand Down Expand Up @@ -185,7 +188,10 @@ def generate(
description += '.'

moderated_description = self.moderate(description)
return self.enhance(moderated_description)

if task in ['t2v', 'i2v']:
return self.enhance(moderated_description)
return moderated_description

def moderate(self, description: str, max_new_tokens: int = 80) -> str:
"""
Expand Down Expand Up @@ -233,34 +239,28 @@ def enhance(self, description: str, max_new_tokens: int = 80) -> str:
"""
Enhance a static image description to make it suitable for video generation
by adding dynamic elements and motion.

Args:
description: The static image description to enhance.
max_new_tokens: Maximum number of new tokens to generate in the enhanced text.

Returns:
An enhanced description suitable for video generation, or the original
description if enhancement fails.
An enhanced description suitable for video generation.
"""
messages = [
{
"role": "system",
"content": (
"[INST]You are an expert at converting static image descriptions "
"into dynamic video prompts. Enhance the given description by "
"adding natural motion and temporal elements while preserving the "
"core scene. Follow these rules:\n"
"1. Maintain the essential elements of the original description\n"
"2. Add smooth, continuous motions that work well in video\n"
"3. For portraits: Add natural facial movements or expressions\n"
"4. For non-portrait images with people: Add contextually appropriate "
"actions (e.g., for a beach scene, people might be walking along "
"the shoreline or playing in the waves; for a cafe scene, people "
"might be sipping drinks or engaging in conversation)\n"
"5. For landscapes: Add environmental motion like wind or water\n"
"6. For urban scenes: Add dynamic elements like people or traffic\n"
"7. Keep the description concise but descriptive\n"
"8. Focus on gradual, natural transitions\n"
"[INST]You are an expert at converting image descriptions into video prompts. "
"Analyze the existing motion in the scene and enhance it naturally:\n"
"1. If motion exists in the image (falling, throwing, running, etc.):\n"
" - Maintain and emphasize that existing motion\n"
" - Add smooth continuation of the movement\n"
"2. If the subject is static (sitting, standing, placed):\n"
" - Keep it stable\n"
" - Add minimal environmental motion if appropriate\n"
"3. Add ONE subtle camera motion that complements the scene\n"
"4. Keep the description concise and natural\n"
"Only respond with the enhanced description.[/INST]"
)
},
Expand All @@ -280,5 +280,5 @@ def enhance(self, description: str, max_new_tokens: int = 80) -> str:
return enhanced_text[0]['generated_text']

except Exception as e:
print(f"An error occurred during motion enhancement: {e}")
return description
bt.logging.error(f"An error occurred during motion enhancement: {e}")
return description
71 changes: 60 additions & 11 deletions bitmind/synthetic_data_generation/synthetic_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
T2V_MODEL_NAMES,
T2I_MODEL_NAMES,
I2I_MODEL_NAMES,
I2V_MODEL_NAMES,
TARGET_IMAGE_SIZE,
select_random_model,
get_task,
Expand Down Expand Up @@ -152,7 +153,12 @@ def batch_generate(self, batch_size: int = 5) -> None:
image_sample = self.image_cache.sample()
images.append(image_sample['image'])
bt.logging.info(f"Sampled image {i+1}/{batch_size} for captioning: {image_sample['path']}")
prompts.append(self.generate_prompt(image=image_sample['image'], clear_gpu=i==batch_size-1))
task = get_task(self.model_name) if self.model_name else None
prompts.append(self.generate_prompt(
image=image_sample['image'],
clear_gpu=i==batch_size-1,
task=task
))
bt.logging.info(f"Caption {i+1}/{batch_size} generated: {prompts[-1]}")

# If specific model is set, use only that model
Expand All @@ -163,9 +169,12 @@ def batch_generate(self, batch_size: int = 5) -> None:
i2i_model_names = random.sample(I2I_MODEL_NAMES, len(I2I_MODEL_NAMES))
t2i_model_names = random.sample(T2I_MODEL_NAMES, len(T2I_MODEL_NAMES))
t2v_model_names = random.sample(T2V_MODEL_NAMES, len(T2V_MODEL_NAMES))
i2v_model_names = random.sample(I2V_MODEL_NAMES, len(I2V_MODEL_NAMES))

model_names = [
m for triple in zip_longest(t2v_model_names, t2i_model_names, i2i_model_names)
for m in triple if m is not None
m for quad in zip_longest(t2v_model_names, t2i_model_names,
i2i_model_names, i2v_model_names)
for m in quad if m is not None
]

# Generate for each model/prompt combination
Expand Down Expand Up @@ -222,7 +231,7 @@ def generate(
ValueError: If real_image is None when using annotation prompt type.
NotImplementedError: If prompt type is not supported.
"""
prompt = self.generate_prompt(image, clear_gpu=True)
prompt = self.generate_prompt(image, clear_gpu=True, task=task)
bt.logging.info("Generating synthetic data...")
gen_data = self._run_generation(prompt, task, model_name, image)
self.clear_gpu()
Expand All @@ -231,7 +240,8 @@ def generate(
def generate_prompt(
self,
image: Optional[Image.Image] = None,
clear_gpu: bool = True
clear_gpu: bool = True,
task: Optional[str] = None
) -> str:
"""Generate a prompt based on the specified strategy."""
bt.logging.info("Generating prompt")
Expand All @@ -241,7 +251,7 @@ def generate_prompt(
"image can't be None if self.prompt_type is 'annotation'"
)
self.prompt_generator.load_models()
prompt = self.prompt_generator.generate(image)
prompt = self.prompt_generator.generate(image, task=task)
if clear_gpu:
self.prompt_generator.clear_gpu()
else:
Expand All @@ -261,9 +271,9 @@ def _run_generation(

Args:
prompt: The text prompt used to inspire the generation.
task: The generation task type ('t2i', 't2v', 'i2i', or None).
task: The generation task type ('t2i', 't2v', 'i2i', 'i2v', or None).
model_name: Optional model name to use for generation.
image: Optional input image for image-to-image generation.
image: Optional input image for image-to-image or image-to-video generation.
generate_at_target_size: If True, generate at TARGET_IMAGE_SIZE dimensions.

Returns:
Expand All @@ -272,6 +282,10 @@ def _run_generation(
Raises:
RuntimeError: If generation fails.
"""
# Clear CUDA cache before loading model
torch.cuda.empty_cache()
gc.collect()

self.load_model(model_name)
model_config = MODELS[self.model_name]
task = get_task(model_name) if task is None else task
Expand All @@ -289,14 +303,38 @@ def _run_generation(

gen_args['mask_image'], mask_center = create_random_mask(image.size)
gen_args['image'] = image
# prep image-to-video generation args
elif task == 'i2v':
if image is None:
raise ValueError("image cannot be None for image-to-video generation")
# Get target size from gen_args if specified, otherwise use default
target_size = (
gen_args.get('height', 768),
gen_args.get('width', 768)
)
if image.size[0] > target_size[0] or image.size[1] > target_size[1]:
image = image.resize(target_size, Image.Resampling.LANCZOS)
gen_args['image'] = image

# Prepare generation arguments
for k, v in gen_args.items():
if isinstance(v, dict):
if "min" in v and "max" in v:
gen_args[k] = np.random.randint(v['min'], v['max'])
# For i2v, use minimum values to save memory
if task == 'i2v':
gen_args[k] = v['min']
else:
gen_args[k] = np.random.randint(v['min'], v['max'])
if "options" in v:
gen_args[k] = random.choice(v['options'])
# Ensure num_frames is always an integer
if k == 'num_frames' and isinstance(v, dict):
if "min" in v:
gen_args[k] = v['min']
elif "max" in v:
gen_args[k] = v['max']
else:
gen_args[k] = 24 # Default value

try:
if generate_at_target_size:
Expand All @@ -307,6 +345,10 @@ def _run_generation(
gen_args['width'] = gen_args['resolution'][1]
del gen_args['resolution']

# Ensure num_frames is an integer before generation
if 'num_frames' in gen_args:
gen_args['num_frames'] = int(gen_args['num_frames'])

truncated_prompt = truncate_prompt_if_too_long(prompt, self.model)
bt.logging.info(f"Generating media from prompt: {truncated_prompt}")
bt.logging.info(f"Generation args: {gen_args}")
Expand All @@ -321,8 +363,14 @@ def _run_generation(
pretrained_args = model_config.get('from_pretrained_args', {})
torch_dtype = pretrained_args.get('torch_dtype', torch.bfloat16)
with torch.autocast(self.device, torch_dtype, cache_enabled=False):
# Clear CUDA cache before generation
torch.cuda.empty_cache()
gc.collect()
gen_output = generate(truncated_prompt, **gen_args)
else:
# Clear CUDA cache before generation
torch.cuda.empty_cache()
gc.collect()
gen_output = generate(truncated_prompt, **gen_args)

gen_time = time.time() - start_time
Expand All @@ -334,6 +382,8 @@ def _run_generation(
f"default dimensions. Error: {e}"
)
try:
# Clear CUDA cache before retry
torch.cuda.empty_cache()
gen_output = self.model(prompt=truncated_prompt)
gen_time = time.time() - start_time
except Exception as fallback_error:
Expand Down Expand Up @@ -461,5 +511,4 @@ def clear_gpu(self) -> None:
del self.model
self.model = None
gc.collect()
torch.cuda.empty_cache()

torch.cuda.empty_cache()
6 changes: 3 additions & 3 deletions bitmind/validator/challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bitmind.utils.uids import get_random_uids
from bitmind.validator.reward import get_rewards
from bitmind.validator.config import (
TARGET_IMAGE_SIZE,
TARGET_IMAGE_SIZE,
MIN_FRAMES,
MAX_FRAMES,
P_STITCH,
Expand Down Expand Up @@ -136,7 +136,7 @@ def sample_video_frames(self, video_cache):
sample['video'] = sample_A['video'] + sample_B['video']

return sample

def process_metadata(self, sample) -> bool:
"""Prepare challenge metadata and media for logging to Weights & Biases """
self.metadata = {
Expand Down Expand Up @@ -179,4 +179,4 @@ def create_wandb_video(video_frames, fps):
except Exception as e:
bt.logging.error(e)
bt.logging.error(f"{self.modality} is truncated or corrupt. Challenge skipped.")
return False
return False
Loading