tugot17 commited on
Commit
0e6f299
1 Parent(s): a8c442e

Upload img_gen_v2.py

Browse files
Files changed (1) hide show
  1. img_gen_v2.py +4 -5
img_gen_v2.py CHANGED
@@ -6,7 +6,6 @@ from diffusers import StableDiffusionImg2ImgPipeline, \
6
 
7
  def check_cuda_device():
8
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
9
- print(device)
10
  return device
11
 
12
 
@@ -40,25 +39,25 @@ def get_image_to_image_model(path=None, device=None):
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=25).images[0]
51
 
52
  return image
53
 
54
 
55
- def generate_story(int_prompt, steps, iterations=25):
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] = {
 
6
 
7
  def check_cuda_device():
8
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
 
9
  return device
10
 
11
 
 
39
  device = check_cuda_device()
40
  pipe.to(device)
41
 
 
 
42
  return pipe
43
 
44
 
45
  def gen_initial_img(int_prompt):
46
  model = get_the_model(None)
47
+ image = model(int_prompt, num_inference_steps=100).images[0]
48
 
49
  return image
50
 
51
 
52
+ def generate_story(int_prompt, steps, iterations=100):
53
  image_dic = {}
54
  init_img = gen_initial_img(int_prompt)
55
  img2img_model = get_image_to_image_model()
56
  img = init_img
57
 
58
  for idx, step in enumerate(steps):
59
+ print(f"step: {idx}")
60
+ print(step)
61
  image = img2img_model(prompt=step, image=img, strength=0.75, guidance_scale=7.5,
62
  num_inference_steps=iterations).images[0]
63
  image_dic[idx] = {