十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

《Python实战 | 当“潮汕英歌舞”遇上水晶梨:用代码生成已申请专利的国潮IP》

《Python实战 | 当“潮汕英歌舞”遇上水晶梨:用代码生成已申请专利的国潮IP》 import torchfrom diffusers import StableDiffusionPipeline, DPMSolverMultistepSchedulerclass ChaoShanIPGenerator:def __init__(self, model_id):# 加载基础模型self.pipe StableDiffusionPipeline.from_pretrained(model_id,torch_dtypetorch.float16,safety_checkerNone)self.pipe.scheduler DPMSolverMultistepScheduler.from_config(self.pipe.scheduler.config)self.pipe.to(cuda)def generate_yingge_pear(self, prompt_text):生成英歌舞与水晶梨结合的IP图# 核心提示词工程强调半透明材质和英歌舞特征base_prompt (cute chibi style, chaozhou yingge dance hero, holding wooden sticks, traditional opera makeup, inside a translucent crystal pear, subsurface scattering, sunset beach background, c4d render style, 8k resolution)# 负向提示词避免生成实体工厂或复杂背景negative_prompt factory, realistic photo, complex background, low qualityimage self.pipe(promptbase_prompt , prompt_text,negative_promptnegative_prompt,guidance_scale7.5, # 提高提示词遵循度num_inference_steps30).images[0]return image# 实例化并运行# generator ChaoShanIPGenerator(your_model_path)# img generator.generate_yingge_pear(dynamic pose)
返回列表