Run this model with HF Jobs
Run SumantBobade/Image_To_3D_Generator on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/SumantBobade/Image_To_3D_Generator. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/SumantBobade/Image_To_3D_Generator on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use SumantBobade/Image_To_3D_Generator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use SumantBobade/Image_To_3D_Generator with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("SumantBobade/Image_To_3D_Generator", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
fix mvdream
Browse filesFiles changed (6)
3 unmodified lines456783 unmodified lines*.pyc
weightsmodelssd-v2*3 unmodified lines4567891011123 unmodified lines
### convert weights```bash# dependencypip install -U omegaconf diffusers safetensors huggingface_hub transformers accelerate
# download original ckptwget https://huggingface.co/MVDream/MVDream/resolve/main/sd-v2.1-base-4view.ptwget https://raw.githubusercontent.com/bytedance/MVDream/main/mvdream/configs/sd-v2-base.yaml404 unmodified lines405406407408409410411412413414415416404 unmodified lines # ) # print(f"Unet Config: {original_config.model.params.unet_config.params}") unet_config = create_unet_config(original_config)
# remove unused configs del unet_config['legacy'] del unet_config['use_linear_in_transformer'] del unet_config['use_spatial_transformer']
unet = MultiViewUNetModel(**unet_config) unet.register_to_config(**unet_config) # print(f"Unet State Dict: {unet.state_dict().keys()}")1231237 unmodified lines11121317141516171819# obtained and modified from https://github.com/bytedance/MVDream
import mathimport torchimport torch.nn as nnimport torch.nn.functional as F7 unmodified linestry: import xformers # type: ignore import xformers.ops # type: ignore
XFORMERS_IS_AVAILBLE = Trueexcept: print(f'[WARN] xformers is unavailable!') XFORMERS_IS_AVAILBLE = False
# CrossAttn precision handling1231232 unmodified lines67812910113 unmodified lines15161722232425182728293031323334192021221 unmodified line242526422728293071 unmodified lines102103104120105106107108165 unmodified lines27427527627727827928088 unmodified lines36937037138637237337437540 unmodified lines41641741843341942042142242342443942542642742821 unmodified lines45045145246745345445545679 unmodified lines536537538553539540541542# obtained and modified from https://github.com/bytedance/MVDream
import mathimport torchimport torch.nn as nnimport torch.nn.functional as F2 unmodified linesfrom typing import Any, List, Optionalfrom torch import Tensor
from abc import abstractmethodfrom .util import ( checkpoint, conv_nd,3 unmodified lines)from .attention import SpatialTransformer, SpatialTransformer3D
class TimestepBlock(nn.Module): """ Any module where forward() takes timestep embeddings as a second argument. """
@abstractmethod def forward(self, x, emb): """ Apply the module to `x` given `emb` timestep embeddings. """
class TimestepEmbedSequential(nn.Sequential, TimestepBlock):class CondSequential(nn.Sequential): """ A sequential module that passes timestep embeddings to the children that support it as an extra input.1 unmodified line
def forward(self, x, emb, context=None, num_frames=1): for layer in self: if isinstance(layer, TimestepBlock): if isinstance(layer, ResBlock): x = layer(x, emb) elif isinstance(layer, SpatialTransformer3D): x = layer(x, context, num_frames=num_frames)71 unmodified lines return self.op(x)
class ResBlock(TimestepBlock):class ResBlock(nn.Module): """ A residual block that can optionally change the number of channels. :param channels: the number of input channels.165 unmodified lines disable_middle_self_attn=False, adm_in_channels=None, camera_dim=None, **kwargs, ): super().__init__() assert context_dim is not None88 unmodified lines
self.input_blocks = nn.ModuleList( [ TimestepEmbedSequential( CondSequential( conv_nd(dims, in_channels, model_channels, 3, padding=1) ) ]40 unmodified lines use_checkpoint=use_checkpoint, ) ) self.input_blocks.append(TimestepEmbedSequential(*layers)) self.input_blocks.append(CondSequential(*layers)) self._feature_size += ch input_block_chans.append(ch) if level != len(channel_mult) - 1: out_ch = ch self.input_blocks.append( TimestepEmbedSequential( CondSequential( ResBlock( ch, time_embed_dim,21 unmodified lines num_heads = ch // num_head_channels dim_head = num_head_channels self.middle_block = TimestepEmbedSequential( self.middle_block = CondSequential( ResBlock( ch, time_embed_dim,79 unmodified lines else Upsample(ch, conv_resample, dims=dims, out_channels=out_ch) ) ds //= 2 self.output_blocks.append(TimestepEmbedSequential(*layers)) self.output_blocks.append(CondSequential(*layers)) self._feature_size += ch
self.out = nn.Sequential(123456789123# adopted from# https://github.com/openai/improved-diffusion/blob/main/improved_diffusion/gaussian_diffusion.py# and# https://github.com/lucidrains/denoising-diffusion-pytorch/blob/7706bdfc6f527f58d33f84b7b522e61e6e3164b3/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py# and# https://github.com/openai/guided-diffusion/blob/0ba878e517b276c45d1195eb29f6f5f72659a05b/guided_diffusion/nn.py## thanks!
import mathimport torchimport torch.nn as nn.gitignore+1
README.md+3
convert_mvdream_to_diffusers.py+6
mvdream/attention.py+1-4
mvdream/models.py+9-23
mvdream/util.py-9