YulianSa commited on
Commit
01416ea
·
1 Parent(s): 522a413

hash changed

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -4,6 +4,7 @@ import numpy as np
4
  import glob
5
  import torch
6
  import random
 
7
  import imagehash
8
  from tempfile import NamedTemporaryFile
9
  from PIL import Image
@@ -86,7 +87,7 @@ tmp_path = '/tmp'
86
  def arbitrary_to_apose(image, seed):
87
  # convert image to PIL.Image
88
  image = Image.fromarray(image)
89
- image_hash = str(imagehash.average_hash(image)) + '_' + str(seed)
90
  if image_hash not in cache_arbitrary:
91
  apose_img = infer_api.genStage1(image, seed)
92
  apose_img.save(f'{tmp_path}/{image_hash}.png')
@@ -101,7 +102,7 @@ def arbitrary_to_apose(image, seed):
101
  def apose_to_multiview(apose_img, seed):
102
  # convert image to PIL.Image
103
  apose_img = Image.fromarray(apose_img)
104
- image_hash = str(imagehash.average_hash(apose_img)) + '_' + str(seed)
105
  if image_hash not in cache_multiview[0]:
106
  results = infer_api.genStage2(apose_img, seed, num_levels=1)
107
  for idx, img in enumerate(results[0]["images"]):
 
4
  import glob
5
  import torch
6
  import random
7
+ import hashlib
8
  import imagehash
9
  from tempfile import NamedTemporaryFile
10
  from PIL import Image
 
87
  def arbitrary_to_apose(image, seed):
88
  # convert image to PIL.Image
89
  image = Image.fromarray(image)
90
+ image_hash = str(hashlib.md5(image.tobytes()).hexdigest()) + '_' + str(seed)
91
  if image_hash not in cache_arbitrary:
92
  apose_img = infer_api.genStage1(image, seed)
93
  apose_img.save(f'{tmp_path}/{image_hash}.png')
 
102
  def apose_to_multiview(apose_img, seed):
103
  # convert image to PIL.Image
104
  apose_img = Image.fromarray(apose_img)
105
+ image_hash = str(hashlib.md5(apose_img.tobytes()).hexdigest()) + '_' + str(seed)
106
  if image_hash not in cache_multiview[0]:
107
  results = infer_api.genStage2(apose_img, seed, num_levels=1)
108
  for idx, img in enumerate(results[0]["images"]):