Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor save_image function for better path handling #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions scripts/TemporalKitImg2ImgTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ def save_image(image, filename, directory):
# save the image to the specified file path
image.save(file_path)


def on_button_click():
global lastimage
extension_path = os.path.abspath(__file__)
extension_dir = os.path.dirname(os.path.dirname(extension_path))
extension_folder = os.path.join(extension_dir,"squares")
extension_dir = os.path.dirname(os.path.dirname(extension_path))
extension_folder = os.path.join(extension_dir, 'squares')

# save the image to the parent directory with a new filename
save_image(lastimage, 'last.png', extension_folder)
Expand All @@ -34,7 +35,7 @@ def on_button_click():
class Script(scripts.Script):
global button
def title(self):
return "TemporalKit"
return 'TemporalKit'

def show(self, is_img2img):
if is_img2img:
Expand All @@ -44,14 +45,14 @@ def show(self, is_img2img):

def ui(self, is_img2img):
global lastimage
savebutton = gr.Button("save", label="Save")
savebutton = gr.Button('save', label='Save')
savebutton.click(
fn=on_button_click,
)
movebutton = gr.Button("move", label="Move")
movebutton = gr.Button('move', label='Move')
movebutton.click(
fn=None,
_js="switch_to_temporal_kit",
_js='switch_to_temporal_kit',
)


Expand All @@ -62,3 +63,4 @@ def run(self, p):
#registerbuttons(button)
return processed