tugot17 commited on
Commit
6fdaf65
1 Parent(s): 9003af0

Upload img_gen_v2.py

Browse files
Files changed (1) hide show
  1. img_gen_v2.py +12 -9
img_gen_v2.py CHANGED
@@ -40,29 +40,32 @@ def get_image_to_image_model(path=None, device=None):
40
  device = check_cuda_device()
41
  pipe.to(device)
42
 
 
 
43
  return pipe
44
 
45
 
46
  def gen_initial_img(int_prompt):
47
- # image = get_the_model(num_inference_steps=100).images[0]
48
  model = get_the_model(None)
49
- image = model(int_prompt, num_inference_steps=100).images[0]
50
 
51
  return image
52
 
53
 
54
- def generate_story(pipe, original_image, steps, iterations=10):
55
  image_dic = {}
56
- img = original_image
 
 
 
57
  for idx, step in enumerate(steps):
58
- print(idx)
59
- image = pipe(prompt=step, image=img, strength=0.75, guidance_scale=7.5,
60
- num_inference_steps=iterations).images[0]
61
- image_dic[f"step_{idx}"] = {
62
  "image": image,
63
  "prompt": step
64
  }
65
  img = image
66
  break
67
 
68
- return image_dic
 
40
  device = check_cuda_device()
41
  pipe.to(device)
42
 
43
+ print(device)
44
+
45
  return pipe
46
 
47
 
48
  def gen_initial_img(int_prompt):
 
49
  model = get_the_model(None)
50
+ image = model(int_prompt, num_inference_steps=10).images[0]
51
 
52
  return image
53
 
54
 
55
+ def generate_story(int_prompt, steps, iterations=10):
56
  image_dic = {}
57
+ init_img = gen_initial_img(int_prompt)
58
+ img2img_model = get_image_to_image_model()
59
+ img = init_img
60
+
61
  for idx, step in enumerate(steps):
62
+ image = img2img_model(prompt=step, image=img, strength=0.75, guidance_scale=7.5,
63
+ num_inference_steps=iterations).images[0]
64
+ image_dic[idx] = {
 
65
  "image": image,
66
  "prompt": step
67
  }
68
  img = image
69
  break
70
 
71
+ return init_img, image_dic