So i’m getting this error (AttributeError: ‘NoneType’ object has no attribute ‘tokenize’) with some models, any direction towards solving this problem will be appreciated, ty. Here is my code below
#@title #Install Dependencies
Install the required files and import modules
!pip install -q --upgrade huggingface_hub
!pip install -q diffusers==0.25.0 accelerate omegaconf xformers transformers gradio mediapy scipy ftfy torchsde k-diffusion fastapi==0.103.2
import mediapy as media
import random
import sys
import torch
import os
from diffusers import DiffusionPipeline
from diffusers.models.attention_processor import AttnProcessor2_0
from diffusers import StableDiffusionXLPipeline, AutoencoderKL, DPMSolverMultistepScheduler
from IPython.display import clear_output
from diffusers import StableDiffusionKDiffusionPipeline
clear_output()
#@title #Download & Load Model
Load model from diffusers
model = “digiplay/RealEpicMajicRevolution_v1” # @param [“digiplay/Realisian_v5”, “SG161222/Realistic_Vision_V6.0_B1_noVAE”, “segmind/SSD-1B”, “digiplay/RealEpicMajicRevolution_v1”, “imagepipeline/Realities-Edge-XL”, “stablediffusionapi/realisian111”] {type:“string”}
pipe = StableDiffusionXLPipeline.from_pretrained(
model,
torch_dtype=torch.float16,
variant=“fp16”,
use_safetensors=True,
requires_safety_checker=None,
)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type=“dpmsolver++”)
Load it to GPU
pipe = pipe.to(‘cuda’)
#@title #Diffusers UI
Define every compunent
prompt = “cute dog playing in field” # @param {type:“string”}
negative_prompt = “bad anatomy, bad face details, low quality, unrealistic, 3d, anime” # @param {type:“string”}
num_inference_steps = 20 # @param {type:“slider”, def:10, min:1, max:100}
selected_resolution = 400, 700 # @param [“1600, 900”,“1280, 720”,“700, 400”,“500, 200”,“200, 500”,“400, 700”,“720, 1280”,“900, 1600”,“512, 512”,“768, 768”,“1024, 1024” ] {type:“raw”}
guidance_scale = 5 # @param {type:“slider”, def:5, min:0, max:10}
seed_input = “1735499402575024878” #@param {type: “string”}
requires_safety_checker = None
pipe.safety_checker = None
Seed randomizer function
if seed_input == “”:
seed = random.randint(0, sys.maxsize)
else:
try:
seed = int(seed_input)
except ValueError:
print(“Invalid input. Please enter a valid number.”)
seed = None
print(“Seed:”, seed)
Optimizations
pipe.enable_xformers_memory_efficient_attention()
Image generation function
images = pipe(
prompt = prompt,
negative_prompt = negative_prompt,
guidance_scale = guidance_scale,
num_inference_steps = num_inference_steps,
width = selected_resolution[0] - selected_resolution[0] % 8,
height = selected_resolution[1] - selected_resolution[1] % 8,
use_karras_sigmas=True,
generator = torch.Generator(“cuda”).manual_seed(seed),
).images
Show image
media.show_images(images)
images[0].save(“output.jpg”)
And My Diffusers Env is below
diffusers
version: 0.25.0- Platform: Linux-6.1.58±x86_64-with-glibc2.35
- Python version: 3.10.12
- PyTorch version (GPU?): 2.1.2+cu121 (True)
- Huggingface_hub version: 0.20.2
- Transformers version: 4.35.2
- Accelerate version: 0.25.0
- xFormers version: 0.0.23.post1
- Using GPU in script?: YES
- Using distributed or parallel set-up in script?: