Adityadn commited on
Commit
5f4438a
·
verified ·
1 Parent(s): f63699a

Delete aiDescTerminal.py

Browse files
Files changed (1) hide show
  1. aiDescTerminal.py +0 -90
aiDescTerminal.py DELETED
@@ -1,90 +0,0 @@
1
- import os
2
- import sys
3
- import numpy as np
4
- from PIL import Image
5
- import requests
6
- from io import BytesIO
7
-
8
- root = os.path.dirname(os.path.abspath(__file__))
9
- sys.path.append(root)
10
- os.chdir(root)
11
-
12
- import modules.config
13
- import modules.html
14
- import modules.flags as flags
15
- import modules.meta_parser
16
-
17
- def download_image(url):
18
- response = requests.get(url)
19
- img = Image.open(BytesIO(response.content)).convert("RGB")
20
- return img
21
-
22
- def trigger_describe(mode, img_path):
23
- print("Running")
24
- print("Press Ctrl+C for Stop ")
25
- if mode == flags.desc_type_photo:
26
- from extras.interrogate import default_interrogator as default_interrogator_photo
27
- if img_path.startswith('http'):
28
- img = download_image(img_path)
29
- else:
30
- img = Image.open(img_path).convert("RGB")
31
- return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"]
32
- elif mode == flags.desc_type_anime:
33
- from extras.wd14tagger import default_interrogator as default_interrogator_anime
34
- if img_path.startswith('http'):
35
- img = download_image(img_path)
36
- elif isinstance(img_path, str):
37
- # Load the image if the input is a path
38
- img = Image.open(img_path).convert("RGB")
39
- elif isinstance(img_path, np.ndarray):
40
- # Use the provided NumPy array directly
41
- img = Image.fromarray(img_path).convert("RGB")
42
- else:
43
- raise ValueError("Invalid image format. Please provide a valid path or NumPy array.")
44
-
45
- # Convert the image to a NumPy array
46
- img_array = np.array(img)
47
-
48
- return default_interrogator_anime(img_array), ["Fooocus V2", "Fooocus Masterpiece"]
49
- return mode, ["Fooocus V2"]
50
-
51
- style_selections = modules.config.default_styles
52
-
53
- def run_describe(image_path, content_type):
54
- desc_input_image = image_path
55
- desc_method = content_type
56
-
57
- result, style_selections = None, None
58
-
59
- if desc_method in ["Photograph", "1", ""]:
60
- desc_method = "Photograph (1)"
61
- result, style_selections = trigger_describe(flags.desc_type_photo, desc_input_image)
62
- elif desc_method in ["Art/Anime", "2"]:
63
- desc_method = "Art/Anime (2)"
64
- result, style_selections = trigger_describe(flags.desc_type_anime, desc_input_image)
65
- else:
66
- print("ERROR!")
67
-
68
- if result or style_selections != "":
69
- style_selections = ""
70
- print("Result:", result)
71
- # print("Style Selections:", style_selections)
72
- quit()
73
-
74
- if __name__ == "__main__":
75
- desc_input_image = input("Path to Image (local path or URL): ")
76
-
77
- if desc_input_image == "":
78
- desc_input_image = "./imgs/Gambar1.jpg"
79
-
80
- print(f"You use: {desc_input_image}")
81
-
82
- desc_method = input(
83
- """
84
- Select Content Type:
85
- Photograph (1)
86
- Art/Anime (2)
87
- """
88
- )
89
-
90
- run_describe(desc_input_image, desc_method)