Spaces:
Runtime error
Runtime error
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 |
-

|
40 |
-

|
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 |
+

|
40 |
+
|
41 |
+

|
42 |
+
|
43 |
+

|
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) :
|