shethjenil commited on
Commit
ec13d50
·
verified ·
1 Parent(s): 8f9c6dc

Upload 2 files

Browse files
Files changed (2) hide show
  1. AIMAGE.exe +2 -2
  2. AIMAGE.py +21 -12
AIMAGE.exe CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9fd8ab82cfea6367852a91068021b9799db42718e160eeb89e8c1e82d09b23c8
3
- size 36301732
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:acb94b451549526fcf57b208b0f5ab9b6cd3cfcae71cc75b10342535a99ad754
3
+ size 38548043
AIMAGE.py CHANGED
@@ -1,12 +1,21 @@
1
- from requests import post
2
- from io import BytesIO
3
- from PIL.Image import open as open_image
4
- from tkinter.simpledialog import askstring
5
-
6
- while True:
7
- text = askstring("IMAGE PROMPT",prompt="What is your prompt?")
8
- if text and text.strip() != "":
9
- hfapi = "<KEY>"
10
- open_image(BytesIO(post("https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0", headers={"Authorization": f"Bearer {hfapi}"}, json={"inputs": text.strip()}).content)).show()
11
- else:
12
- break
 
 
 
 
 
 
 
 
 
 
1
+ try:
2
+ from requests import post
3
+ from io import BytesIO
4
+ from PIL.Image import open as open_image
5
+ from tkinter.simpledialog import askstring
6
+ from tkinter.messagebox import showerror
7
+ hfapi = "hf_token"
8
+ while True:
9
+ text = askstring("IMAGE PROMPT",prompt="What is your prompt?")
10
+ if text and text.strip() != "":
11
+ postreq = post("https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0", headers={"Authorization": f"Bearer {hfapi}"}, json={"inputs": text.strip()})
12
+ if postreq.status_code == 200:
13
+ open_image(BytesIO(postreq.content)).show()
14
+ else:
15
+ showerror("ERROR",f"Error: Software is out of service or your internet connection is not working.")
16
+ break
17
+ else:
18
+ break
19
+ except Exception:
20
+ showerror("ERROR",f"Error: Software is out of service or your internet connection is not working.")
21
+