Spaces:
Sleeping
Sleeping
drakosfire
commited on
Commit
•
60c7d21
1
Parent(s):
f5c9fe7
more cleanup, removed torch, not needed in api scenario
Browse files- .git.bfg-report/2024-04-26/20-35-39/cache-stats.txt +4 -0
- .git.bfg-report/2024-04-26/20-35-39/deleted-files.txt +2 -0
- .git.bfg-report/2024-04-26/20-35-39/object-id-map.old-new.txt +30 -0
- README.md +7 -3
- app.py +0 -6
- item_dict_gen.py +1 -4
- render_card_text.py +1 -1
- template_builder.py +1 -1
- user_input.py +0 -3
- utilities.py +0 -19
.git.bfg-report/2024-04-26/20-35-39/cache-stats.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(apply,CacheStats{hitCount=330, missCount=217, loadSuccessCount=216, loadExceptionCount=0, totalLoadTime=205192304, evictionCount=0})
|
2 |
+
(tree,CacheStats{hitCount=523, missCount=160, loadSuccessCount=148, loadExceptionCount=0, totalLoadTime=239549818, evictionCount=0})
|
3 |
+
(commit,CacheStats{hitCount=125, missCount=114, loadSuccessCount=114, loadExceptionCount=0, totalLoadTime=50895256, evictionCount=0})
|
4 |
+
(tag,CacheStats{hitCount=0, missCount=0, loadSuccessCount=0, loadExceptionCount=0, totalLoadTime=0, evictionCount=0})
|
.git.bfg-report/2024-04-26/20-35-39/deleted-files.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
9ac261c89cd43d40203c77c0fd0881dd143771e0 1052412 Armor.jpeg
|
2 |
+
75c8f82592ed35f3a390b4c6c5702fd46072f86d 132 Armor.jpeg
|
.git.bfg-report/2024-04-26/20-35-39/object-id-map.old-new.txt
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
00eb9c0e5818d6eb3e690d4b3e5d79ad4d533d4f 85036659d4f97d4df32320e8db1eec803f3d831a
|
2 |
+
030e08f2654c50bcdf23ff3de5038d2ebf60a921 c4abe73ed55add642f915ea21457dbec3b697bd0
|
3 |
+
060c977a835c7f4dd2e5022f8a6c9b1c87e453fe 029bc4b282c219ee2b1a1c7d4b15c69345701065
|
4 |
+
12ab77e670a3dfd573bccdd73830a5b6c52e3bb5 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
5 |
+
1a7c80b285ef9547eb6e1640f2f18e3a7b224b40 85751491515504b430808948555c5dbab4f58c5a
|
6 |
+
1b267393ec0cb87fa58df315cf459f188b81fc3d d2c5369f2a677902892e79f45b2692d293355074
|
7 |
+
20bb25a4ec7baa362264c5e2c6d0404692a6ccb6 45221e092660096ff4c7991ee71a7149aa3d815b
|
8 |
+
29eb4dea6c5d395bdec404fe268c018c74ef282c 6615e336259507ad5eee442fdc9c572076e59760
|
9 |
+
2f2e240de243ac8ce312ae5e7db72af54853b4df 48ae952b7dcc65b46f6cb5c3b1ebcd0c6d858a28
|
10 |
+
3dbee5f8aa1f322b44ffb0e11a2735cd76b1cefb 4c72c3547b4fd257f5c91450015b6d7bed62873b
|
11 |
+
4a0df3c63609d8a9e1cbb62d0fb16e8f1286c7d5 9d7e8700394b9e914055f35a09bd4d8f28e134a8
|
12 |
+
4b9368ae1c8eafef19be76df7885bca81f740f76 f94ce26df9b6e458376fc41407f51c22d4218d36
|
13 |
+
5db8d744d85df65cae2fd1c0d78623e5d00755ea 71e614ffa436a26a2fe8038f202d26e32839101b
|
14 |
+
5f6fe9812a6726c528b8ce2d24301e62fe6b3eae 698b15861fad294a9a68aad5381c0ed54449cd6e
|
15 |
+
651d00dede5c3e5d3f1b5c177c1f7ea4d15c9343 e22f5d79a77fc202924e4d618d4dda903d3e7a3b
|
16 |
+
738f243ee7c773bb5f07436dc713d5522ed01e2a f30c6efa29a9cad656ff09879ff93193dd66f8aa
|
17 |
+
7adc776d5c2208c2398a698d6be1e1d02c4b0131 3803ffdd6f14cf12b4ed86405e1e79a0909366fc
|
18 |
+
7b455ac9eeaa688b234a784037a103969411be5c 64d60e07f5fcdb52d747e1e3c2285dce1efd02e4
|
19 |
+
86acd4c67b83c7a9cc9c47e30823ce06f034c37a 4d4d2f7e0de62a6ca19690132b22b4058ff68e31
|
20 |
+
8904b6f5e847447154fce01f979aa36f7de535b9 6dc153f27266e24181d0eea2a2384cbbec658221
|
21 |
+
9122506743aa9d3f1daa77e04948c40ae290c58c 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
22 |
+
93ffd1f4ff39bee20b103e9e7597a0eea5c67246 76691e1f4958c3afb6de653dc29495696b0c1086
|
23 |
+
99ac67d6400583ee70b8c11adc0d874185b89042 094b9f23035eef77fcd453b56cf135a12ac51dab
|
24 |
+
9d7aea9cfdf2fac1674429d49edd4c351bfc2df7 2656b55da6b7c247af69f27764718f8b26de0a03
|
25 |
+
b6bbdb8878532ebb12154015c81f352530bd9474 fb3cc5d46d3219919977593ede6ed8fc6f01a5b5
|
26 |
+
ba55e907b5ca6050c0707355c582ddc6e1fa4fc9 ac2380cd225658e55942c6a0af2fddc47886ad0f
|
27 |
+
d1087e6099c9f9f28eb509ebc56d7dc5774fa773 2996a25e9b1eaa7fe75f2bf4076ef4cedf7ec966
|
28 |
+
df702a7cb1001765d0fa17629a3572730ba02983 c96720d9c749a07d5232406bb6d1a0ff4ba6f564
|
29 |
+
e4b2f40834014ea5504825c65bd9b1574835ea44 700322496f7350c067ed2eaefce8d72979b8f71e
|
30 |
+
fe14efa884a08011353a4e2f5ebf1198eea7186c 066b02f605ae7316b021a60a9f58f7a7622b1504
|
README.md
CHANGED
@@ -34,9 +34,13 @@ This generator leverages an API call to [Replicate](https://replicate.com/) usin
|
|
34 |
|
35 |
## Example Cards
|
36 |
|
37 |
-
Below are a few examples of the item cards generated
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
![Example Card 1](url-to-example-card1)
|
40 |
-
![Example Card 2](url-to-example-card2)
|
41 |
|
42 |
We hope you enjoy enhancing your Dungeons and Dragons experience with this unique tool. Happy adventuring!
|
|
|
34 |
|
35 |
## Example Cards
|
36 |
|
37 |
+
Below are a few examples of the item cards I've generated:
|
38 |
+
|
39 |
+
![Carved Wooden Dinosaur Toy](https://cdn-lfs-us-1.huggingface.co/repos/cb/b4/cbb436e53a2021c9535cec40c6360a89a1d6f5e42bc18d88bbd2da335dde82bd/aa2ca06939fa4db1c30631f01f389e40f2b3f8018e91cfbb127eed56f31e70e8?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27CarvedWoodenDinosaurToy.png%3B+filename%3D%22CarvedWoodenDinosaurToy.png%22%3B&response-content-type=image%2Fpng&Expires=1714445274&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxNDQ0NTI3NH19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2NiL2I0L2NiYjQzNmU1M2EyMDIxYzk1MzVjZWM0MGM2MzYwYTg5YTFkNmY1ZTQyYmMxOGQ4OGJiZDJkYTMzNWRkZTgyYmQvYWEyY2EwNjkzOWZhNGRiMWMzMDYzMWYwMWYzODllNDBmMmIzZjgwMThlOTFjZmJiMTI3ZWVkNTZmMzFlNzBlOD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=gfGIhG1lNGANcRcaRo69v9G2IyT%7ETVaSv69ELCzSQ1r9ybHF-TvZAikiWWjWv1lrfubAPmwF3Wmvih7YreEqMgVr6rbxWmqVK%7EjO%7Eylz5Ow8wQM8a9dyiYn874oV0Uz34inXRejJ6JK7FquX%7EZcm95qcqKUhNjjl6hkN3OqbMRhViYqClDl3VhKOgvI0CPJTSfYxPOfNGwPPZoW2d%7EAQRSYeT6gex3CrE8H73wND4pTfOiDRHy3EfHm3pF%7EGjYcnQRaBm%7EMPSe93I7cmu05EgVwX-LsQAYxDLeFAkCIi3qJTrbBxRG551g%7Ew3%7E1iwfWtcOZi3vqWLWpKkNJcrpBX4g__&Key-Pair-Id=KCD77M1F0VK2B)
|
40 |
+
|
41 |
+
![Cookie Mimic](https://cdn-lfs-us-1.huggingface.co/repos/cb/b4/cbb436e53a2021c9535cec40c6360a89a1d6f5e42bc18d88bbd2da335dde82bd/10a137ac3cf8bcb509423f626788af61c27989847cd8c6b23bf36e59443a3bde?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27CookieMimic.png%3B+filename%3D%22CookieMimic.png%22%3B&response-content-type=image%2Fpng&Expires=1714445306&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxNDQ0NTMwNn19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2NiL2I0L2NiYjQzNmU1M2EyMDIxYzk1MzVjZWM0MGM2MzYwYTg5YTFkNmY1ZTQyYmMxOGQ4OGJiZDJkYTMzNWRkZTgyYmQvMTBhMTM3YWMzY2Y4YmNiNTA5NDIzZjYyNjc4OGFmNjFjMjc5ODk4NDdjZDhjNmIyM2JmMzZlNTk0NDNhM2JkZT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=YRlqcf2gr0cb1sgJr4O-SXsj0q%7EgcJ6rWc%7E1TOSJoKC11J8LUCj1FRf6yTus5xlXbA97Zek-ynUGFAbOKkfY5TctoHECjX3cB5GJb6VmC47YUQmG4DggamnD2qGwTP37h-120u-uKeciK9FAtOqz1vQZW01IlkZYybaaSuo0pdyqiyaq%7E1ywI-B63gaQbgrN8RelwhB9x%7E0y0x-KiwM80xAD%7E5tBDruHRp2HAIT3AWVKKxLZelAKBNog5KTOrwF9cyE6q1m-IW9LKyrbazUNISU8h8QPts04VQH0hd66ZKg1YaNV5l%7EwhCem9wGkJ18p2ZNMYFEH6W4-85%7EuYsKM5A__&Key-Pair-Id=KCD77M1F0VK2B)
|
42 |
+
|
43 |
+
![Ridiculously Cute Kitten](https://cdn-lfs-us-1.huggingface.co/repos/cb/b4/cbb436e53a2021c9535cec40c6360a89a1d6f5e42bc18d88bbd2da335dde82bd/863ef9235c94e60fd7176db237e3939f67c6a22bce3015712ff2336a49065f83?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27Ridiculouslycutekitten.png%3B+filename%3D%22Ridiculouslycutekitten.png%22%3B&response-content-type=image%2Fpng&Expires=1714445494&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxNDQ0NTQ5NH19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2NiL2I0L2NiYjQzNmU1M2EyMDIxYzk1MzVjZWM0MGM2MzYwYTg5YTFkNmY1ZTQyYmMxOGQ4OGJiZDJkYTMzNWRkZTgyYmQvODYzZWY5MjM1Yzk0ZTYwZmQ3MTc2ZGIyMzdlMzkzOWY2N2M2YTIyYmNlMzAxNTcxMmZmMjMzNmE0OTA2NWY4Mz9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=Awm-rIF7be1FRdKIU2zR-cxZa3KtR7FcYmPgVTqfaa2oMKZhU2vkG3lLHXimFvVuXbiv8Rd4ZnijffjWyEBWs6FV5L2JFQ2jG%7EDhlBIdWj-6skbvYwgxsbAfDclBbBv3zyZs%7EDK0rzEqvIDdd8Avud9NtXvyMpSFZTx2zUzGMp1saHLaYH2uU91z7zWHLhnL0XVW1JvY6RbaNx0Ydtx42r1IWqVpLqpB6yGoeIU2PBQCpNiuY61zwjOCg2iMM3OuXJ56eULFXtnrbJbqDSZnlIibELCZ%7EJQCozeVSvi-OK6HOkD7W7tPSnbfx2f9GIY1FkmzoXh-K7cFNL-CxYnCjw__&Key-Pair-Id=KCD77M1F0VK2B)
|
44 |
|
|
|
|
|
45 |
|
46 |
We hope you enjoy enhancing your Dungeons and Dragons experience with this unique tool. Happy adventuring!
|
app.py
CHANGED
@@ -6,12 +6,6 @@ import user_input as useri
|
|
6 |
import gradio as gr
|
7 |
import template_builder as tb
|
8 |
|
9 |
-
# This is a fix for the way that python doesn't release system memory back to the OS and it was leading to locking up the system
|
10 |
-
libc = ctypes.cdll.LoadLibrary("libc.so.6")
|
11 |
-
M_MMAP_THRESHOLD = -3
|
12 |
-
|
13 |
-
# Set malloc mmap threshold.
|
14 |
-
libc.mallopt(M_MMAP_THRESHOLD, 2**20)
|
15 |
initial_name = "A Crowbar"
|
16 |
|
17 |
with gr.Blocks() as demo:
|
|
|
6 |
import gradio as gr
|
7 |
import template_builder as tb
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
initial_name = "A Crowbar"
|
10 |
|
11 |
with gr.Blocks() as demo:
|
item_dict_gen.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import replicate
|
2 |
import ast
|
3 |
import gc
|
4 |
-
import torch
|
5 |
import os
|
6 |
|
7 |
api_key = os.getenv('REPLICATE_API_TOKEN')
|
@@ -21,9 +20,7 @@ def call_llm_and_cleanup(user_input):
|
|
21 |
llm_output = "".join(load_llm(user_input))
|
22 |
print("".join(llm_output))
|
23 |
gc.collect()
|
24 |
-
|
25 |
-
torch.cuda.empty_cache() # Clear VRAM allocated by PyTorch
|
26 |
-
|
27 |
# llm_output is still available for use here
|
28 |
|
29 |
return llm_output
|
|
|
1 |
import replicate
|
2 |
import ast
|
3 |
import gc
|
|
|
4 |
import os
|
5 |
|
6 |
api_key = os.getenv('REPLICATE_API_TOKEN')
|
|
|
20 |
llm_output = "".join(load_llm(user_input))
|
21 |
print("".join(llm_output))
|
22 |
gc.collect()
|
23 |
+
|
|
|
|
|
24 |
# llm_output is still available for use here
|
25 |
|
26 |
return llm_output
|
render_card_text.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from PIL import
|
2 |
|
3 |
# Function for managing longer bodies of text and breaking into a list of lines to be printed based on input arguments
|
4 |
def split_text_into_lines(text, font, max_width, draw):
|
|
|
1 |
+
from PIL import ImageDraw, ImageFont
|
2 |
|
3 |
# Function for managing longer bodies of text and breaking into a list of lines to be printed based on input arguments
|
4 |
def split_text_into_lines(text, font, max_width, draw):
|
template_builder.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from PIL import Image
|
2 |
import utilities as u
|
3 |
|
4 |
# Function to initialize image canvas
|
|
|
1 |
+
from PIL import Image
|
2 |
import utilities as u
|
3 |
|
4 |
# Function to initialize image canvas
|
user_input.py
CHANGED
@@ -3,8 +3,6 @@ import img2img
|
|
3 |
import card_generator as card
|
4 |
import utilities as u
|
5 |
import sys
|
6 |
-
import tempfile
|
7 |
-
from PIL import Image
|
8 |
from github import Github
|
9 |
|
10 |
image_path = str
|
@@ -87,7 +85,6 @@ def prompt_user_input():
|
|
87 |
response = call_llm(user_input_item)
|
88 |
print(response[u.keys_list(response,0)])
|
89 |
output_dict = response[u.keys_list(response,0)]
|
90 |
-
u.reclaim_mem()
|
91 |
item_name = response[u.keys_list(response,0)]['Name']
|
92 |
sd_prompt = response[u.keys_list(response,0)]['SD Prompt']
|
93 |
image_path = img2img.generate_image(4,sd_prompt,item_name,user_input_template, mimic)
|
|
|
3 |
import card_generator as card
|
4 |
import utilities as u
|
5 |
import sys
|
|
|
|
|
6 |
from github import Github
|
7 |
|
8 |
image_path = str
|
|
|
85 |
response = call_llm(user_input_item)
|
86 |
print(response[u.keys_list(response,0)])
|
87 |
output_dict = response[u.keys_list(response,0)]
|
|
|
88 |
item_name = response[u.keys_list(response,0)]['Name']
|
89 |
sd_prompt = response[u.keys_list(response,0)]['SD Prompt']
|
90 |
image_path = img2img.generate_image(4,sd_prompt,item_name,user_input_template, mimic)
|
utilities.py
CHANGED
@@ -1,12 +1,7 @@
|
|
1 |
-
# Create a list of hashmap key values .
|
2 |
-
import torch
|
3 |
-
import time
|
4 |
-
import gc
|
5 |
from io import BytesIO
|
6 |
import requests
|
7 |
import os
|
8 |
from PIL import Image
|
9 |
-
from pathlib import Path
|
10 |
|
11 |
image_list = []
|
12 |
# Utility Functions to be called from all modules
|
@@ -16,20 +11,6 @@ def keys_list(dict, index):
|
|
16 |
keys_list=list(dict.keys())
|
17 |
return keys_list[index]
|
18 |
|
19 |
-
# Function to clear model from VRAM to make space for other model
|
20 |
-
def reclaim_mem():
|
21 |
-
|
22 |
-
print(f"Memory before del {torch.cuda.memory_allocated()}")
|
23 |
-
torch.cuda.ipc_collect()
|
24 |
-
gc.collect()
|
25 |
-
torch.cuda.empty_cache()
|
26 |
-
time.sleep(0.01)
|
27 |
-
print(f"Memory after del {torch.cuda.memory_allocated()}")
|
28 |
-
|
29 |
-
#def del_object(object):
|
30 |
-
# del object
|
31 |
-
# gc.collect()
|
32 |
-
|
33 |
# Create a list of a directory if directory exists
|
34 |
def directory_contents(directory_path):
|
35 |
if os.path.isdir(directory_path) :
|
|
|
|
|
|
|
|
|
|
|
1 |
from io import BytesIO
|
2 |
import requests
|
3 |
import os
|
4 |
from PIL import Image
|
|
|
5 |
|
6 |
image_list = []
|
7 |
# Utility Functions to be called from all modules
|
|
|
11 |
keys_list=list(dict.keys())
|
12 |
return keys_list[index]
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Create a list of a directory if directory exists
|
15 |
def directory_contents(directory_path):
|
16 |
if os.path.isdir(directory_path) :
|