fantaxy commited on
Commit
9211d08
·
verified ·
1 Parent(s): 1a46abc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -17,12 +17,20 @@ api_client = Client("http://211.233.58.202:7960/")
17
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
18
 
19
  # Imgur 클라이언트 ID
20
- IMGUR_CLIENT_ID = "4990123196cbfcc"
21
  imgur_client = pyimgur.Imgur(IMGUR_CLIENT_ID)
22
 
 
 
 
 
 
 
23
  def upload_to_imgur(image_path):
24
  try:
25
- uploaded_image = imgur_client.upload_image(image_path, title="Generated Image")
 
 
26
  return uploaded_image.link
27
  except Exception as e:
28
  logging.error(f"Failed to upload image to Imgur: {e}")
@@ -77,6 +85,7 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
77
  return "Failed to generate image due to an error."
78
 
79
 
 
80
  css = """
81
  footer {
82
  visibility: hidden;
 
17
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
18
 
19
  # Imgur 클라이언트 ID
20
+ IMGUR_CLIENT_ID = "여기에_당신의_IMGUR_CLIENT_ID를_입력하세요"
21
  imgur_client = pyimgur.Imgur(IMGUR_CLIENT_ID)
22
 
23
+ def convert_to_png(image_path):
24
+ with Image.open(image_path) as img:
25
+ png_path = image_path.rsplit('.', 1)[0] + '.png'
26
+ img.save(png_path, 'PNG')
27
+ return png_path
28
+
29
  def upload_to_imgur(image_path):
30
  try:
31
+ png_path = convert_to_png(image_path)
32
+ uploaded_image = imgur_client.upload_image(png_path, title="Generated Image")
33
+ os.remove(png_path) # 임시 PNG 파일 삭제
34
  return uploaded_image.link
35
  except Exception as e:
36
  logging.error(f"Failed to upload image to Imgur: {e}")
 
85
  return "Failed to generate image due to an error."
86
 
87
 
88
+
89
  css = """
90
  footer {
91
  visibility: hidden;