LL3RD commited on
Commit
eb7f1b6
·
1 Parent(s): 0275bf6
Files changed (2) hide show
  1. app.py +17 -2
  2. output_images/no_bg_image.png +0 -3
app.py CHANGED
@@ -14,6 +14,8 @@ from transformers import AutoModelForImageSegmentation
14
  from torchvision import transforms
15
  import torch
16
  import subprocess
 
 
17
  subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
18
  generated_images = []
19
 
@@ -35,6 +37,17 @@ def remove_bg(image):
35
  mask = transforms.ToPILImage()(preds).resize(im.size)
36
  return mask
37
 
 
 
 
 
 
 
 
 
 
 
 
38
  class DreamFuseGUI:
39
  def __init__(self):
40
  self.examples = [
@@ -440,6 +453,7 @@ class DreamFuseGUI:
440
  ), draggable_img
441
 
442
 
 
443
  def create_gui(self):
444
  config = InferenceConfig()
445
  config.lora_id = 'LL3RD/DreamFuse'
@@ -450,10 +464,11 @@ class DreamFuseGUI:
450
 
451
  with gr.Blocks(css=self.css_style) as demo:
452
  modified_fg_state = gr.State()
 
453
  gr.HTML(
454
- """
455
  <div style="display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px;">
456
- <img src="./examples/logo.png" style="height: 40px;" />
457
  <h1 style="margin: 0; font-size: 32px;">DreamFuse</h1>
458
  </div>
459
  """
 
14
  from torchvision import transforms
15
  import torch
16
  import subprocess
17
+ import base64
18
+
19
  subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
20
  generated_images = []
21
 
 
37
  mask = transforms.ToPILImage()(preds).resize(im.size)
38
  return mask
39
 
40
+
41
+
42
+
43
+ def get_base64_logo(path="examples/logo.png"):
44
+ image = Image.open(path).convert("RGBA")
45
+ buffered = BytesIO()
46
+ image.save(buffered, format="PNG")
47
+ base64_img = base64.b64encode(buffered.getvalue()).decode()
48
+ return f"data:image/png;base64,{base64_img}"
49
+
50
+
51
  class DreamFuseGUI:
52
  def __init__(self):
53
  self.examples = [
 
453
  ), draggable_img
454
 
455
 
456
+
457
  def create_gui(self):
458
  config = InferenceConfig()
459
  config.lora_id = 'LL3RD/DreamFuse'
 
464
 
465
  with gr.Blocks(css=self.css_style) as demo:
466
  modified_fg_state = gr.State()
467
+ logo_data_url = get_base64_logo()
468
  gr.HTML(
469
+ f"""
470
  <div style="display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px;">
471
+ <img src="{logo_data_url}" style="height: 80px;" />
472
  <h1 style="margin: 0; font-size: 32px;">DreamFuse</h1>
473
  </div>
474
  """
output_images/no_bg_image.png DELETED

Git LFS Details

  • SHA256: 339a905140e7f12e9443ce8acc5455b89c198a6ddda6e94f322797fedb2c04c8
  • Pointer size: 131 Bytes
  • Size of remote file: 496 kB