brentvollebregt / auto-py-to-exe

Converts .py to .exe using a simple graphical interface
MIT License
3.95k stars 677 forks source link

Unused models in the application #478

Closed Roboxkin closed 6 months ago

Roboxkin commented 6 months ago

Hello! I can’t figure out how to make sure that only the necessary extensions are collected in the application. No matter how much I try, I always get 1.5 - 2 gigabytes.

my code

from free_verify_proxy import VerifyProxyLists
from flask import Flask, request
from color50 import rgb, constants
from fp.fp import FreeProxy
import cv2
import cv2 as cv
from PIL import Image
import numpy as np
from dominant_color_recognizer import ColorAnalyzer, HEXColorModel

app = Flask(__name__)

success_color = rgb(50, 168, 82)
fail_color = rgb(168, 74, 50)
other_color = rgb(168, 135, 50)
print(other_color + 'App version 1.0.1' + constants.RESET)

@app.route("/")
def home_page():
    return "this home page, what did you forget here?"

@app.route("/proxylist", methods=["GET"])
def proxylist():
    try:
        one = request.args["proxy"]
        if one == 'proxy':
            try:
                print(other_color + 'Proxy request, please wait...' + constants.RESET)
                proxy = FreeProxy(anonym=True, google=True).get()
                print(success_color + f'Proxy request, success {proxy}' + constants.RESET)
                return f'Proxy request, success {proxy}'
            except:
                print(fail_color + 'Sorry, Proxy request fail' + constants.RESET)
                return 'Sorry, Proxy request fail'
    except:
        try:
            print(other_color + 'Proxy list request, please wait...' + constants.RESET)
            proxy = VerifyProxyLists().get_verifyProxyLists(number_of_threads=300, timeout=(3, 5))
            print(success_color + f'Proxy list success {proxy}' + constants.RESET)
            return f'Proxy list success {proxy}'
        except:
            print(fail_color + 'Sorry, proxy list fail' + constants.RESET)
            return 'Sorry, proxy list fail'

@app.route("/image", methods=["GET"])
def image():
    if request.method == "GET":
        try:
            captcha = request.args["capa"]
            # color = request.args["color"]

            dominant = ColorAnalyzer(HEXColorModel()).get_dominant_colors(captcha, 4)

            def loadimg(imgname):
                dominant1 = dominant[0].lstrip('#')
                dominant_one = tuple(int(dominant1[i:i + 2], 16) for i in (0, 2, 4))

                img = Image.open(imgname)
                width, height = img.size
                im = np.array(img)
                for x in range(width):
                    for y in range(height):
                        r = im[y, x, 0]
                        g = im[y, x, 1]
                        b = im[y, x, 2]
                        sr = (r, g, b)
                        if sr == dominant_one:
                            im[y, x] = (0, 0, 0, 0)

                img = Image.fromarray(im)
                img.save(captcha)

            img = loadimg(captcha)

            imgs = cv2.imread(captcha, cv2.COLOR_BGR2GRAY)
            cv2.imwrite(captcha, imgs)

            print(success_color + f'success response image color {dominant}' + constants.RESET)
            return f'success response image color {dominant}'
        except:
            print(fail_color + 'Sorry, image color no response' + constants.RESET)
            return 'Sorry, image color no response'

if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8888, debug=False)

After assembling the application, a 40MB file is obtained (this is permissible) and a folder with extensions at 1.8 GB. Without a folder, the application does not launch and there are extensions in the folder that are not needed. those. it collects everything that is installed (pip list) I'm writing through Google Translate, sorry if anything is wrong

python 3.10.11 auro py to exe last (just updated today)

github-actions[bot] commented 6 months ago

👋 Hi, just a reminder that if you haven't read the help post yet, give it a read to see if your issue is covered in it and make sure to follow the debugging section.

Also please note, as stated in the README, if your issue is only associated with your application and not auto-py-to-exe itself, please do not create an issue in this repository - instead, comment on the help post, video or create a new discussion.

brentvollebregt commented 6 months ago

I trust you read the help post - when you follow the steps under "The Output Executable is Huge" do you see a size difference?

Roboxkin commented 6 months ago

I trust you read the help post - when you follow the steps under "The Output Executable is Huge" do you see a size difference?

Thank you very much for the answer! To be honest, I didn’t read it, but I opened the link and immediately understood what the problem was. Thank you very much for pointing me to the right place and helping me with this issue.