Needed updates working now

This commit is contained in:
joe
2023-08-06 14:20:11 +09:00
parent d74e90106f
commit d1aa40f1f4
3 changed files with 58 additions and 49 deletions

View File

@@ -41,6 +41,7 @@ global_timer_paused = False
emotion = "joy"
fps = 0
current_pose = None
storepath = os.path.join(os.getcwd(), "live2d")
# Flask setup
app = Flask(__name__)
@@ -101,6 +102,7 @@ def live2d_load_file(stream):
global global_reload
global global_timer_paused
global_timer_paused = False
try:
pil_image = Image.open(stream) # Load the image using PIL.Image.open
img_data = BytesIO() # Create a copy of the image data in memory using BytesIO
@@ -309,7 +311,9 @@ class MainFrame(wx.Frame):
return output
def get_emotion_values(self, emotion): # Place to define emotion presets
file_path = r"live2d\emotions.json"
global storepath
file_path = storepath + "\emotions.json"
with open(file_path, 'r') as json_file:
emotions = json.load(json_file)
@@ -317,7 +321,7 @@ class MainFrame(wx.Frame):
targetpose_values = targetpose
#targetpose_values = list(targetpose.values())
print("targetpose: ", targetpose, "for ", emotion)
#print("targetpose: ", targetpose, "for ", emotion)
return targetpose_values
def animateToEmotion(self, current_pose_list, target_pose_str):

View File

@@ -6,6 +6,7 @@ import PIL.Image
import numpy
import torch
import wx
import json
from typing import List
# Set the working directory to the "live2d" subdirectory to work with file structure
@@ -462,15 +463,16 @@ class MainFrame(wx.Frame):
pil_image.save(image_file_name)
data_str = str(self.get_current_posedict()) # Get values
txt_file_path = os.path.splitext(image_file_name)[0] + ".txt"
data_dict = self.get_current_posedict() # Get values
json_file_path = os.path.splitext(image_file_name)[0] + ".json" # Generate JSON file path
filename_without_extension = os.path.splitext(os.path.basename(image_file_name))[0]
data_str_with_filename = "'{}': {}".format(filename_without_extension, data_str)
data_dict_with_filename = {filename_without_extension: data_dict} # Create a new dict with the filename as the key
with open(json_file_path, "w") as file:
json.dump(data_dict_with_filename, file, indent=4)
with open(txt_file_path, "w") as file:
file.write(data_str_with_filename)
if __name__ == "__main__":