You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any thoughts on why I am not able to reproduce the same resolution reported out there:
Weights: I downloaded weights from Huggingface to local and loaded it from local directory
Model: Janus-Pro-7B
@torch.inference_mode()
def generate_image(prompt, seed, guidance):
"""
Generate multiple images for a given prompt.
"""
torch.cuda.empty_cache()
seed = seed if seed is not None else 12345
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
np.random.seed(seed)
width = 384
height = 384
parallel_size = 16
with torch.no_grad():
# Prepare text
messages = [
{'role': 'User', 'content': prompt},
{'role': 'Assistant', 'content': ''}
]
text = vl_chat_processor.apply_sft_template_for_multi_turn_prompts(
conversations=messages,
sft_format=vl_chat_processor.sft_format,
system_prompt=''
)
text = text + vl_chat_processor.image_start_tag
input_ids = torch.LongTensor(tokenizer.encode(text)).to(cuda_device)
_, patches = generate(
input_ids,
width // 16 * 16,
height // 16 * 16,
cfg_weight=guidance,
parallel_size=parallel_size
)
images = unpack(patches, width // 16 * 16, height // 16 * 16)
# Convert to PIL and upscale
return [
Image.fromarray(images[i]).resize((1024, 1024), Image.LANCZOS)
for i in range(parallel_size)
]
The text was updated successfully, but these errors were encountered:
bjohn22
changed the title
resolution issues
output image resolution details issues
Feb 2, 2025
Any thoughts on why I am not able to reproduce the same resolution reported out there:
Weights: I downloaded weights from Huggingface to local and loaded it from local directory
Model:
Janus-Pro-7B
Prompt
python "/home/mytemp/Documents/ml_projects/Janus/janus_run_script.py" generate --prompt "Elephant on Dallas Texas street" --seed 142 --guidance 5.0
Here is my text to image snippet:
def generate(input_ids,
width,
height,
temperature: float = 1,
parallel_size: int = 16,
cfg_weight: float = 5,
image_token_num_per_image: int = 576,
patch_size: int = 16):
"""
Internal method that generates image patches from the text input.
"""
torch.cuda.empty_cache()
tokens = torch.zeros((parallel_size * 2, len(input_ids)), dtype=torch.int).to(cuda_device)
def unpack(dec, width, height, parallel_size=16):
"""
Convert raw patches into final numpy images.
"""
dec = dec.to(torch.float32).cpu().numpy().transpose(0, 2, 3, 1)
dec = np.clip((dec + 1) / 2 * 255, 0, 255)
@torch.inference_mode()
def generate_image(prompt, seed, guidance):
"""
Generate multiple images for a given prompt.
"""
torch.cuda.empty_cache()
seed = seed if seed is not None else 12345
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
np.random.seed(seed)
The text was updated successfully, but these errors were encountered: