ChandimaPrabath commited on
Commit
4bede7e
·
verified ·
1 Parent(s): e7299cf

Update sd.py

Browse files
Files changed (1) hide show
  1. sd.py +3 -4
sd.py CHANGED
@@ -17,7 +17,7 @@ def load_config():
17
  with open('config.yaml', 'r') as f:
18
  return yaml.safe_load(f)
19
 
20
- def upload_to_imgbb(image_data):
21
  """
22
  Uploads image data to ImgBB and returns the URL.
23
 
@@ -32,10 +32,9 @@ def upload_to_imgbb(image_data):
32
  "https://api.imgbb.com/1/upload",
33
  params={
34
  "key": IMGBB_API_KEY,
35
- "expiration": 600 # Optional: Set expiration time in seconds
36
  },
37
  files={
38
- "image": ("image.jpg", image_data)
39
  }
40
  )
41
  response.raise_for_status()
@@ -100,7 +99,7 @@ def generate_sd(prompt):
100
  f.write(image_data)
101
 
102
  # Upload image to ImgBB
103
- image_url = upload_to_imgbb(image_data)
104
 
105
  # Convert the path to use forward slashes
106
  image_path = image_path.replace('\\', '/')
 
17
  with open('config.yaml', 'r') as f:
18
  return yaml.safe_load(f)
19
 
20
+ def upload_to_imgbb(image_data, file_name):
21
  """
22
  Uploads image data to ImgBB and returns the URL.
23
 
 
32
  "https://api.imgbb.com/1/upload",
33
  params={
34
  "key": IMGBB_API_KEY,
 
35
  },
36
  files={
37
+ "image": (file_name, image_data)
38
  }
39
  )
40
  response.raise_for_status()
 
99
  f.write(image_data)
100
 
101
  # Upload image to ImgBB
102
+ image_url = upload_to_imgbb(image_data, image_filename)
103
 
104
  # Convert the path to use forward slashes
105
  image_path = image_path.replace('\\', '/')