We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
比如:一位ins风格网红清纯小姐姐,全身照片,双腿站立,眼睛看镜头 但是不能生成全身照还是只有脸的照片,确实脸生成无敌,但是想要半身、全身照怎么做? 我的代码如下:
import os import torch import uuid import random from flask import Flask, request, jsonify from kolors.pipelines.pipeline_stable_diffusion_xl_chatglm_256 import StableDiffusionXLPipeline from kolors.models.modeling_chatglm import ChatGLMModel from kolors.models.tokenization_chatglm import ChatGLMTokenizer from diffusers import UNet2DConditionModel, AutoencoderKL from diffusers import EulerDiscreteScheduler app = Flask(__name__) root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ckpt_dir = f'{root_dir}/weights/Kolors' text_encoder = ChatGLMModel.from_pretrained( f'{ckpt_dir}/text_encoder', torch_dtype=torch.float16).half() tokenizer = ChatGLMTokenizer.from_pretrained(f'{ckpt_dir}/text_encoder') vae = AutoencoderKL.from_pretrained(f"{ckpt_dir}/vae", revision=None).half() scheduler = EulerDiscreteScheduler.from_pretrained(f"{ckpt_dir}/scheduler") unet = UNet2DConditionModel.from_pretrained(f"{ckpt_dir}/unet", revision=None).half() pipe = StableDiffusionXLPipeline( vae=vae, text_encoder=text_encoder, tokenizer=tokenizer, unet=unet, scheduler=scheduler, force_zeros_for_empty_prompt=False) pipe = pipe.to("cuda") pipe.enable_model_cpu_offload() @app.route('/generate', methods=['POST']) def generate(): data = request.json prompt = data.get('prompt', '') if not prompt: return jsonify({'error': 'No prompt provided'}), 400 images = pipe( prompt=prompt, height=720, width=1280, num_inference_steps=50, guidance_scale=5.0, num_images_per_prompt=4, generator=torch.Generator(pipe.device).manual_seed(random.randint(0, 100000000))).images image_urls = [] for image in images: uid = uuid.uuid4() image_path = f'/home/li/work/projects/githubProjects/Kolors/work/app/images/{uid}.jpg' image.save(image_path) image_urls.append(image_path) return jsonify({'image_urls': image_urls}) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
比如:一位ins风格网红清纯小姐姐,全身照片,双腿站立,眼睛看镜头
但是不能生成全身照还是只有脸的照片,确实脸生成无敌,但是想要半身、全身照怎么做?
我的代码如下:
The text was updated successfully, but these errors were encountered: