Surn commited on
Commit
ee02840
·
1 Parent(s): ba8de52
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +20 -15
  3. utils/image_utils.py +0 -1
README.md CHANGED
@@ -37,7 +37,7 @@ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-
37
  Welcome to HexaGrid Creator, the ultimate tool for transforming your images into mesmerizing hexagon grid masterpieces! Whether you're a tabletop game enthusiast, a digital artist, or just someone who loves unique patterns, HexaGrid Creator has something for you.
38
 
39
  ### What Can You Do?
40
- - **Generate Hexagon Grids:** Create stunning hexagon grid overlays on any image with fully customizable parameters.
41
  - **AI-Powered Image Generation:** Use AI to generate images based on your prompts and apply hexagon grids to them.
42
  - **Color Exclusion:** Pick and exclude specific colors from your hexagon grid for a cleaner and more refined look.
43
  - **Interactive Customization:** Adjust hexagon size, border size, rotation, background color, and more in real-time.
 
37
  Welcome to HexaGrid Creator, the ultimate tool for transforming your images into mesmerizing hexagon grid masterpieces! Whether you're a tabletop game enthusiast, a digital artist, or just someone who loves unique patterns, HexaGrid Creator has something for you.
38
 
39
  ### What Can You Do?
40
+ - **Generate Hexagon Grids:** Create stunning hexagon grid overlays on any image with fully customizable parameters. (also square and triangles)
41
  - **AI-Powered Image Generation:** Use AI to generate images based on your prompts and apply hexagon grids to them.
42
  - **Color Exclusion:** Pick and exclude specific colors from your hexagon grid for a cleaner and more refined look.
43
  - **Interactive Customization:** Adjust hexagon size, border size, rotation, background color, and more in real-time.
app.py CHANGED
@@ -96,7 +96,7 @@ from diffusers import (
96
  FluxPipeline,
97
  FluxImg2ImgPipeline,
98
  FluxControlPipeline,
99
- FluxControlPipeline,
100
  DiffusionPipeline,
101
  AutoencoderTiny,
102
  AutoencoderKL
@@ -106,7 +106,7 @@ PIPELINE_CLASSES = {
106
  "FluxPipeline": FluxPipeline,
107
  "FluxImg2ImgPipeline": FluxImg2ImgPipeline,
108
  "FluxControlPipeline": FluxControlPipeline,
109
- "FluxFillPipeline": FluxControlPipeline
110
  }
111
 
112
  from utils.version_info import (
@@ -126,7 +126,7 @@ selected_index = gr.State(value=-1)
126
  image_processor: Optional[DPTImageProcessor] = None
127
  depth_model: Optional[DPTForDepthEstimation] = None
128
  TRELLIS_PIPELINE: Optional[TrellisImageTo3DPipeline] = None
129
- pipe: Optional[Union[FluxPipeline, FluxImg2ImgPipeline, FluxControlPipeline]] = None
130
 
131
  def start_session(req: gr.Request):
132
  print(f"Starting session with hash: {req.session_hash}")
@@ -455,11 +455,16 @@ def generate_image_lowmem(
455
  #conditions.append(condition)
456
  print(f"\nAdded conditioned image.\n {conditioned_image.size}")
457
  # Prepare the parameters for image generation
458
- additional_parameters ={
459
- "strength": strength,
460
- "image": conditioned_image,
461
- }
462
- additional_parameters.update(mask_parameters)
 
 
 
 
 
463
  else:
464
  print("\nNo conditioned image provided.")
465
  if neg_prompt!=None:
@@ -482,8 +487,8 @@ def generate_image_lowmem(
482
  additional_parameters.update(prompt_parameters)
483
  # Combine all parameters
484
  generate_params = {
485
- "height": image_height,
486
- "width": image_width,
487
  "guidance_scale": guidance_scale,
488
  "num_inference_steps": num_inference_steps,
489
  "generator": generator,
@@ -638,7 +643,7 @@ def generate_input_image_click(image_input, map_option, prompt_textbox_value, ne
638
  if (model == "black-forest-labs/FLUX.1-Fill-dev"):
639
  pipeline = "FluxFillPipeline"
640
  width, height = calculate_optimal_fill_dimensions(conditioned_image)
641
- mask_image = get_image_from_dict(mask_image)
642
  print(f"Optimal Dimensions: {width} x {height} \n")
643
  else:
644
  mask_image = None
@@ -1124,7 +1129,7 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
1124
  HexaGrid Creator is a web-based application that allows you to apply a hexagon grid overlay to any image. You can customize the size, color, and opacity of the hexagons, as well as the background and border colors. The result is a visually striking image that looks like it was made from hexagonal tiles!
1125
 
1126
  ### What Can You Do?
1127
- - **Generate Hexagon Grids:** Create beautiful hexagon grid overlays on any image with fully customizable parameters.
1128
  - **AI-Powered Image Generation:** Use advanced AI models to generate images based on your prompts and apply hexagon grids to them.
1129
  - **Color Exclusion:** Select and exclude specific colors from your hexagon grid for a cleaner and more refined look.
1130
  - **Interactive Customization:** Adjust hexagon size, border size, rotation, background color, and more in real-time.
@@ -1173,7 +1178,7 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
1173
  label="Sketch Image",
1174
  type="filepath",
1175
  #invert_colors=True,
1176
- #sources=['upload','canvas'],
1177
  #tool=['editor','select','color-sketch'],
1178
  placeholder="Draw a sketch or upload an image.",
1179
  interactive=True,
@@ -1181,7 +1186,7 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
1181
  key="imgSketch",
1182
  image_mode="RGBA",
1183
  format="PNG",
1184
- brush=gr.Brush(),
1185
  canvas_size=(640,360)
1186
  )
1187
  with gr.Row():
@@ -1189,7 +1194,7 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
1189
  sketch_replace_input_image_button = gr.Button("Replace Input Image with sketch", elem_id="sketch_replace_input_image_button", elem_classes="solid")
1190
  sketch_alpha_composite_slider = gr.Slider(0,100,50,0.5, label="Sketch Transparancy", elem_id="alpha_composite_slider")
1191
  btn_sketch_alpha_composite = gr.Button("Overlay Sketch on Input Image", elem_id="btn_sketchninput", elem_classes="solid")
1192
- gr.Markdown("### Do Not add to image if using a fill model")
1193
 
1194
  with gr.Column(scale=1):
1195
  with gr.Accordion("Hex Coloring and Exclusion", open = False):
 
96
  FluxPipeline,
97
  FluxImg2ImgPipeline,
98
  FluxControlPipeline,
99
+ FluxFillPipeline,
100
  DiffusionPipeline,
101
  AutoencoderTiny,
102
  AutoencoderKL
 
106
  "FluxPipeline": FluxPipeline,
107
  "FluxImg2ImgPipeline": FluxImg2ImgPipeline,
108
  "FluxControlPipeline": FluxControlPipeline,
109
+ "FluxFillPipeline": FluxFillPipeline
110
  }
111
 
112
  from utils.version_info import (
 
126
  image_processor: Optional[DPTImageProcessor] = None
127
  depth_model: Optional[DPTForDepthEstimation] = None
128
  TRELLIS_PIPELINE: Optional[TrellisImageTo3DPipeline] = None
129
+ pipe: Optional[Union[FluxPipeline, FluxImg2ImgPipeline, FluxControlPipeline, FluxFillPipeline]] = None
130
 
131
  def start_session(req: gr.Request):
132
  print(f"Starting session with hash: {req.session_hash}")
 
455
  #conditions.append(condition)
456
  print(f"\nAdded conditioned image.\n {conditioned_image.size}")
457
  # Prepare the parameters for image generation
458
+ if mask_parameters == {}:
459
+ additional_parameters ={
460
+ "strength": strength,
461
+ "image": conditioned_image,
462
+ }
463
+ else:
464
+ additional_parameters ={
465
+ "image": conditioned_image,
466
+ }
467
+ additional_parameters.update(mask_parameters)
468
  else:
469
  print("\nNo conditioned image provided.")
470
  if neg_prompt!=None:
 
487
  additional_parameters.update(prompt_parameters)
488
  # Combine all parameters
489
  generate_params = {
490
+ "height": int(image_height),
491
+ "width": int(image_width),
492
  "guidance_scale": guidance_scale,
493
  "num_inference_steps": num_inference_steps,
494
  "generator": generator,
 
643
  if (model == "black-forest-labs/FLUX.1-Fill-dev"):
644
  pipeline = "FluxFillPipeline"
645
  width, height = calculate_optimal_fill_dimensions(conditioned_image)
646
+ mask_image, _ = get_image_from_dict(mask_image)
647
  print(f"Optimal Dimensions: {width} x {height} \n")
648
  else:
649
  mask_image = None
 
1129
  HexaGrid Creator is a web-based application that allows you to apply a hexagon grid overlay to any image. You can customize the size, color, and opacity of the hexagons, as well as the background and border colors. The result is a visually striking image that looks like it was made from hexagonal tiles!
1130
 
1131
  ### What Can You Do?
1132
+ - **Generate Hexagon Grids:** Create beautiful hexagon grid overlays on any image with fully customizable parameters. (also square and triangles)
1133
  - **AI-Powered Image Generation:** Use advanced AI models to generate images based on your prompts and apply hexagon grids to them.
1134
  - **Color Exclusion:** Select and exclude specific colors from your hexagon grid for a cleaner and more refined look.
1135
  - **Interactive Customization:** Adjust hexagon size, border size, rotation, background color, and more in real-time.
 
1178
  label="Sketch Image",
1179
  type="filepath",
1180
  #invert_colors=True,
1181
+ sources=['upload','clipboard'],
1182
  #tool=['editor','select','color-sketch'],
1183
  placeholder="Draw a sketch or upload an image.",
1184
  interactive=True,
 
1186
  key="imgSketch",
1187
  image_mode="RGBA",
1188
  format="PNG",
1189
+ brush=gr.Brush(colors=['#000000', '#3270cc', '#cc3232', '#32cc70', '#ffffff']),
1190
  canvas_size=(640,360)
1191
  )
1192
  with gr.Row():
 
1194
  sketch_replace_input_image_button = gr.Button("Replace Input Image with sketch", elem_id="sketch_replace_input_image_button", elem_classes="solid")
1195
  sketch_alpha_composite_slider = gr.Slider(0,100,50,0.5, label="Sketch Transparancy", elem_id="alpha_composite_slider")
1196
  btn_sketch_alpha_composite = gr.Button("Overlay Sketch on Input Image", elem_id="btn_sketchninput", elem_classes="solid")
1197
+ gr.Markdown("### Do Not add to image if using a fill model. <span style='color: red; font-style: bolder;'>Click the pencil to start drawing.</span>")
1198
 
1199
  with gr.Column(scale=1):
1200
  with gr.Accordion("Hex Coloring and Exclusion", open = False):
utils/image_utils.py CHANGED
@@ -480,7 +480,6 @@ def alpha_composite_with_control(base_image, image_with_alpha, alpha_percent=100
480
  new_image_path = os.path.join(directory, name + f"_alpha{str(alpha_percent)}.png")
481
  result.save(new_image_path)
482
  return new_image_path
483
- return blended_image
484
  return result
485
 
486
  def apply_alpha_mask(image, mask_image, invert = False):
 
480
  new_image_path = os.path.join(directory, name + f"_alpha{str(alpha_percent)}.png")
481
  result.save(new_image_path)
482
  return new_image_path
 
483
  return result
484
 
485
  def apply_alpha_mask(image, mask_image, invert = False):