gaur3009 commited on
Commit
679424a
·
verified ·
1 Parent(s): 6f12752

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -6,6 +6,7 @@ import torch
6
  import base64
7
  from io import BytesIO
8
  from PIL import Image
 
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
 
@@ -22,7 +23,7 @@ MAX_SEED = np.iinfo(np.int32).max
22
  MAX_IMAGE_SIZE = 1024
23
 
24
  def infer(prompt_part1, color, dress_type, design, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
25
- prompt = f"{prompt_part1} {color} colored {dress_type} with {design} design, {prompt_part5}"
26
 
27
  if randomize_seed:
28
  seed = random.randint(0, MAX_SEED)
@@ -39,12 +40,12 @@ def infer(prompt_part1, color, dress_type, design, prompt_part5, negative_prompt
39
  generator=generator
40
  ).images[0]
41
 
42
- # Convert the PIL image to base64
43
- buffered = BytesIO()
44
- image.save(buffered, format="PNG")
45
- img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
46
 
47
- return img_str
48
 
49
  examples = [
50
  ["red", "t-shirt", "yellow stripes"],
 
6
  import base64
7
  from io import BytesIO
8
  from PIL import Image
9
+ import tempfile
10
 
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
12
 
 
23
  MAX_IMAGE_SIZE = 1024
24
 
25
  def infer(prompt_part1, color, dress_type, design, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
26
+ prompt = f"{prompt_part1} {color} colored {dress_type} with {design} design, {prompt_part5} and also show the back, left and right side of the cloth in the form of collage with the front view"
27
 
28
  if randomize_seed:
29
  seed = random.randint(0, MAX_SEED)
 
40
  generator=generator
41
  ).images[0]
42
 
43
+ # Save the image to a temporary file
44
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
45
+ image.save(temp_file, format="PNG")
46
+ temp_file_path = temp_file.name
47
 
48
+ return temp_file_path
49
 
50
  examples = [
51
  ["red", "t-shirt", "yellow stripes"],