Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,38 +14,19 @@ from dataclasses import dataclass, field
|
|
14 |
from typing import List
|
15 |
|
16 |
st.set_page_config(layout="wide")
|
17 |
-
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
18 |
-
logger = logging.getLogger(__name__)
|
19 |
-
|
20 |
-
@dataclass
|
21 |
-
class AppConfig:
|
22 |
-
MAX_SEED: int = np.iinfo(np.int32).max
|
23 |
-
DEFAULT_WIDTH: int = 1280
|
24 |
-
DEFAULT_HEIGHT: int = 720
|
25 |
-
SUPPORTED_FORMATS: List[str] = field(default_factory=lambda: ["9:16", "16:9", "1:1"])
|
26 |
-
CLEANUP_DAYS: int = 7
|
27 |
-
MAX_GALLERY_SIZE: int = 1000
|
28 |
-
|
29 |
-
credentials = {"username": "", "password": ""}
|
30 |
|
31 |
try:
|
32 |
-
with open("
|
33 |
-
|
34 |
-
credentials["username"] = file_credentials.get("username", credentials["username"])
|
35 |
-
credentials["password"] = file_credentials.get("password", credentials["password"])
|
36 |
except Exception as e:
|
37 |
-
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
"models": ["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-dev"],
|
44 |
-
"storage": {"cleanup_after_days": 7, "max_gallery_size": 1000}
|
45 |
-
}
|
46 |
-
}
|
47 |
|
48 |
-
MAX_SEED = AppConfig.MAX_SEED
|
49 |
client = InferenceClient()
|
50 |
DATA_PATH = Path("./data")
|
51 |
DATA_PATH.mkdir(exist_ok=True)
|
@@ -100,7 +81,7 @@ def swap_faces(source_image, source_face_index, destination_image, destination_f
|
|
100 |
def generate_image(prompt, width, height, seed, model_name):
|
101 |
try:
|
102 |
with st.spinner("Generando imagen..."):
|
103 |
-
seed = int(seed) if seed != -1 else random.randint(0, MAX_SEED)
|
104 |
image = client.text_to_image(
|
105 |
prompt=prompt,
|
106 |
height=height,
|
|
|
14 |
from typing import List
|
15 |
|
16 |
st.set_page_config(layout="wide")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
try:
|
19 |
+
with open("config.yaml", "r") as file:
|
20 |
+
credentials = yaml.safe_load(file)
|
|
|
|
|
21 |
except Exception as e:
|
22 |
+
st.error(f"Error al cargar el archivo de configuraci贸n: {e}")
|
23 |
+
credentials = {"username": "", "password": ""}
|
24 |
|
25 |
+
@dataclass
|
26 |
+
class AppConfig:
|
27 |
+
MAX_SEED: int = 1000000
|
28 |
+
CLEANUP_DAYS: int = 7
|
|
|
|
|
|
|
|
|
29 |
|
|
|
30 |
client = InferenceClient()
|
31 |
DATA_PATH = Path("./data")
|
32 |
DATA_PATH.mkdir(exist_ok=True)
|
|
|
81 |
def generate_image(prompt, width, height, seed, model_name):
|
82 |
try:
|
83 |
with st.spinner("Generando imagen..."):
|
84 |
+
seed = int(seed) if seed != -1 else random.randint(0, AppConfig.MAX_SEED)
|
85 |
image = client.text_to_image(
|
86 |
prompt=prompt,
|
87 |
height=height,
|