🚧 Add Quickposes model download #39
@ -4,3 +4,4 @@ pygame~=2.4.0
|
|||||||
customtkinter~=5.1.3
|
customtkinter~=5.1.3
|
||||||
configparser~=5.3.0
|
configparser~=5.3.0
|
||||||
CTkToolTip~=0.4
|
CTkToolTip~=0.4
|
||||||
|
requests~=2.32.3
|
@ -1,8 +1,16 @@
|
|||||||
|
import io
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
import tkinter
|
import tkinter
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
import customtkinter
|
import customtkinter
|
||||||
|
import requests
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
from src.entity.config import Config
|
from src.entity.config import Config
|
||||||
from src.util import Util
|
from src.util import Util
|
||||||
from src.window.image import ImageWindow
|
from src.window.image import ImageWindow
|
||||||
@ -25,6 +33,10 @@ class App:
|
|||||||
self.title = customtkinter.CTkLabel(root, text="Drawing Training")
|
self.title = customtkinter.CTkLabel(root, text="Drawing Training")
|
||||||
self.title.pack()
|
self.title.pack()
|
||||||
|
|
||||||
|
self.download_from_reference = customtkinter.CTkButton(root, text="Download 3 images from sketch daily",
|
||||||
|
command=self.download_from_reference)
|
||||||
|
self.download_from_reference.pack()
|
||||||
|
|
||||||
self.folder_selector = customtkinter.CTkButton(root, text="Select a folder", command=self.select_folder)
|
self.folder_selector = customtkinter.CTkButton(root, text="Select a folder", command=self.select_folder)
|
||||||
self.folder_selector.pack()
|
self.folder_selector.pack()
|
||||||
|
|
||||||
@ -49,7 +61,8 @@ class App:
|
|||||||
|
|
||||||
self.buttons = []
|
self.buttons = []
|
||||||
for i, timer in enumerate(timers):
|
for i, timer in enumerate(timers):
|
||||||
new_button = customtkinter.CTkButton(self.button_frame, width=10, text=timer, command=lambda t=timer: self.set_timer_in_seconds(t))
|
new_button = customtkinter.CTkButton(self.button_frame, width=10, text=timer,
|
||||||
|
command=lambda t=timer: self.set_timer_in_seconds(t))
|
||||||
new_button.pack(side=tkinter.LEFT, fill=X, expand=True)
|
new_button.pack(side=tkinter.LEFT, fill=X, expand=True)
|
||||||
self.buttons.append(new_button)
|
self.buttons.append(new_button)
|
||||||
|
|
||||||
@ -83,6 +96,31 @@ class App:
|
|||||||
self.find_images_in_folder()
|
self.find_images_in_folder()
|
||||||
self.check_lets_draw()
|
self.check_lets_draw()
|
||||||
|
|
||||||
|
def download_from_reference(self):
|
||||||
|
dt = datetime.now()
|
||||||
|
ts = int(datetime.timestamp(dt))
|
||||||
|
url = 'https://quickposes.com/ajax/getPosesForSlider/Chiaroscuro?_=' + str(ts)
|
||||||
|
|
||||||
|
resp_json = requests.get(url=url)
|
||||||
|
if resp_json.status_code == 200:
|
||||||
|
data = resp_json.json()
|
||||||
|
c = 0
|
||||||
|
for src in data:
|
||||||
|
if c >= 3:
|
||||||
|
break
|
||||||
|
buffer = tempfile.SpooledTemporaryFile(max_size=1e9)
|
||||||
|
r = requests.get('https://quickposes.com/assets/poses/' + src['src'], stream=True)
|
||||||
|
if r.status_code == 200:
|
||||||
|
downloaded = 0
|
||||||
|
for chunk in r.iter_content(chunk_size=1024):
|
||||||
|
downloaded += len(chunk)
|
||||||
|
buffer.write(chunk)
|
||||||
|
buffer.seek(0)
|
||||||
|
i = Image.open(io.BytesIO(buffer.read()))
|
||||||
|
i.save(os.path.join(self.selected_folder, src['src']), quality=85)
|
||||||
|
buffer.close()
|
||||||
|
c += 1
|
||||||
|
|
||||||
def find_images_in_folder(self):
|
def find_images_in_folder(self):
|
||||||
if Path(self.selected_folder).exists():
|
if Path(self.selected_folder).exists():
|
||||||
self.found_images = list(
|
self.found_images = list(
|
||||||
@ -99,7 +137,8 @@ class App:
|
|||||||
def set_timer_in_seconds(self, user_data):
|
def set_timer_in_seconds(self, user_data):
|
||||||
# resetting buttons states
|
# resetting buttons states
|
||||||
for button in self.buttons:
|
for button in self.buttons:
|
||||||
button.configure(fg_color=(Util.get_default_button_color() if user_data != button.cget("text") else Util.get_default_active_button_color()))
|
button.configure(fg_color=(Util.get_default_button_color() if user_data != button.cget(
|
||||||
|
"text") else Util.get_default_active_button_color()))
|
||||||
|
|
||||||
self.custom = False
|
self.custom = False
|
||||||
if user_data == "Custom":
|
if user_data == "Custom":
|
||||||
|
Loading…
Reference in New Issue
Block a user