Spaces:
Build error
Build error
hysts commited on
Commit ·
23b1ff8
1
Parent(s): 80d903f
Update
Browse files19 unmodified lines20212223242542 unmodified lines686970717273747519 unmodified linesThis is an unofficial demo for <a href="https://github.com/yumingj/Text2Human">https://github.com/yumingj/Text2Human</a>.You can modify sample steps and seeds. By varying seeds, you can sample different human images under the same pose, shape description, and texture description. The larger the sample steps, the better quality of the generated images. (The default value of sample steps is 256 in the original repo.)'''FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=hysts.text2human" />'42 unmodified lineswith gr.Row():label_image = gr.Image(label='Label Image',type='numpy',elem_id='label-image',interactive=False)with gr.Row():shape_text = gr.Textbox(label='Shape Description',19 unmodified lines202122232425262742 unmodified lines7071727374757619 unmodified linesThis is an unofficial demo for <a href="https://github.com/yumingj/Text2Human">https://github.com/yumingj/Text2Human</a>.You can modify sample steps and seeds. By varying seeds, you can sample different human images under the same pose, shape description, and texture description. The larger the sample steps, the better quality of the generated images. (The default value of sample steps is 256 in the original repo.)Label image generation step can be skipped. However, in that case, the input label image must be 512x256 in size and must contain only the specified colors.'''FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=hysts.text2human" />'42 unmodified lineswith gr.Row():label_image = gr.Image(label='Label Image',type='numpy',elem_id='label-image')with gr.Row():shape_text = gr.Textbox(label='Shape Description',
51 unmodified lines52535455565726 unmodified lines8485868788899091929330 unmodified lines12412512612712812951 unmodified linesself.config['device'] = deviceself._download_models()self.model = SampleFromPoseModel(self.config)def _load_config(self) -> dict:path = 'Text2Human/configs/sample_from_pose.yml'26 unmodified lines@staticmethoddef process_mask(mask: torch.Tensor) -> torch.Tensor:seg_map = np.full(mask.shape[:-1], -1)for index, color in enumerate(COLOR_LIST):seg_map[np.sum(mask == color, axis=2) == 3] = indexassert (seg_map != -1).all()return seg_map@staticmethod30 unmodified linesreturnmask = label_image.copy()seg_map = self.process_mask(mask)self.model.segm = torch.from_numpy(seg_map).unsqueeze(0).unsqueeze(0).to(self.model.device)self.model.generate_quantized_segm()51 unmodified lines5253545556575826 unmodified lines8586878889909192939495969730 unmodified lines12812913013113213313413551 unmodified linesself.config['device'] = deviceself._download_models()self.model = SampleFromPoseModel(self.config)self.model.batch_size = 1def _load_config(self) -> dict:path = 'Text2Human/configs/sample_from_pose.yml'26 unmodified lines@staticmethoddef process_mask(mask: torch.Tensor) -> torch.Tensor:if mask.shape != (512, 256, 3):return Noneseg_map = np.full(mask.shape[:-1], -1)for index, color in enumerate(COLOR_LIST):seg_map[np.sum(mask == color, axis=2) == 3] = indexif not (seg_map != -1).all():return Nonereturn seg_map@staticmethod30 unmodified linesreturnmask = label_image.copy()seg_map = self.process_mask(mask)if seg_map is None:returnself.model.segm = torch.from_numpy(seg_map).unsqueeze(0).unsqueeze(0).to(self.model.device)self.model.generate_quantized_segm()
app.py+3-2
model.py+7-1