Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Annotation Moderation and FLUX Model Integration #65

Merged
merged 53 commits into from
Oct 16, 2024

Conversation

benliang99
Copy link
Contributor

This PR upgrades our synthetic image pipeline with a new state-of-the-art (SOTA) model and various quality of life enhancements. It introduces Black Forest Labs' advanced FLUX.1-dev model, upgrades our BLIP-2 annotation model from 2.7B to 6.7B parameters, and incorporates Unsloth's Meta-Llama-3.1-8B-Instruct-bnb-4bit for image moderation. Further refinements include optimized parameterization for both CPU and GPU operations, streamlined .env setup for automatic login credentials management, and verification of model loading before a validation starts.

Key Changes

Model Upgrades and Enhancements:

  • Model Integration: Added Black Forest Labs' FLUX.1-dev model for SOTA synthetic image generation capabilities.
  • Annotation Model Upgrade: Transitioned from Salesforce's "blip2-opt-2.7b-coco" to "blip2-opt-6.7b-coco" to enhance image annotation detail and precision.
  • Text Moderation: Implemented Unsloth's "Meta-Llama-3.1-8B-Instruct-bnb-4bit" for adding coherence and removing bias and redundancy in image annotations.
  • Diffusion Models: Added GPU-specific loading for better parallel processing and added stress tests for evaluating diffusion models generation latency.
  • Configuration Enhancements: Improved parameterization for CPU offload and diffusion settings and specified torch data types for computational efficiency.

Infrastructure and Configuration:

  • Configuration Management: Updated min_compute.yml to detail new GPU requirements like tflops.
  • Validator Setup: Upgraded setup_validator_env.sh and start_validator.sh to automate Weights * Biases API key and Hugging Face token user login.
  • Model Verification: Implemented a verification script for initial model download and load testing, now part of the autoupdate_validator_steps.sh sequence and executed prior to start_validator.sh. This modification eliminates the initial download delay when models are loaded for the first time.

Code Quality and Maintenance:

  • Conducted general code cleanup (unnecessary imports, spacing).

dylanuys and others added 30 commits August 12, 2024 03:24
@benliang99 benliang99 requested review from aliang322, dylanuys and kenobijon and removed request for kenobijon September 23, 2024 10:38
bitmind/constants.py Outdated Show resolved Hide resolved
bitmind/constants.py Outdated Show resolved Hide resolved
autoupdate_validator_steps.sh Outdated Show resolved Hide resolved
bitmind/constants.py Outdated Show resolved Hide resolved
@@ -39,19 +41,36 @@
{
"path": "stabilityai/stable-diffusion-xl-base-1.0",
"use_safetensors": True,
"torch_dtype": torch.float16,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch_dtype is no longer hardcoded, so it must be specified in the pipeline / DIFFUSER_ARGS.

"path": 'black-forest-labs/FLUX.1-dev',
"use_safetensors": True,
"torch_dtype": torch.bfloat16,
"generate_args": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguments decided based on experimental generation latencies.

} for m in VALIDATOR_MODEL_META['diffusers']
}

GENERATE_ARGS = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New field for generation arguments, which FLUX-1.dev can utilize.

@@ -80,11 +140,17 @@ def generate_description(self,

if not verbose:
transformers_logging.set_verbosity_info()


if description.startswith(prompts[0]):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for the moderation model repeating the prompt in its response.

@@ -122,9 +136,13 @@ def clear_gpu(self):
torch.cuda.empty_cache()
self.diffuser = None

def load_diffuser(self, diffuser_name) -> None:
def load_diffuser(self, diffuser_name, gpu_id=None) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added GPU parameterization for image generation parallelization. Defaults to cuda if not specified (previous behavior).

start_validator.sh Outdated Show resolved Hide resolved
@benliang99 benliang99 merged commit 27576bc into testnet Oct 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants