guardiancc commited on
Commit
f13f9ba
·
verified ·
1 Parent(s): 4423c83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -68
app.py CHANGED
@@ -1,4 +1,4 @@
1
- '''import sys
2
  import asyncio
3
  from aiohttp import web, WSMsgType
4
  import json
@@ -130,70 +130,4 @@ if __name__ == "__main__":
130
  web.run_app(app, host="0.0.0.0", port=8080)
131
  except Exception as e:
132
  logger.critical(f"🚨 FATAL: Failed to start the app: {str(e)}")
133
- logger.exception("Full traceback:")
134
- '''
135
-
136
- import sys
137
- import asyncio
138
- from aiohttp import web, WSMsgType
139
- import json
140
- from json import JSONEncoder
141
- import numpy as np
142
- import uuid
143
- import logging
144
- import os
145
- import signal
146
- from typing import Dict, Any, List, Optional
147
- import base64
148
- import io
149
- from PIL import Image
150
- import gradio as gr
151
- import pillow_avif
152
-
153
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
154
- logger = logging.getLogger(__name__)
155
-
156
- def SIGSEGV_signal_arises(signalNum, stack):
157
- logger.critical(f"{signalNum} : SIGSEGV arises")
158
- logger.critical(f"Stack trace: {stack}")
159
-
160
- signal.signal(signal.SIGSEGV, SIGSEGV_signal_arises)
161
-
162
- from loader import initialize_models
163
- from engine import Engine, base64_data_uri_to_PIL_Image
164
-
165
- # Global constants
166
- DATA_ROOT = os.environ.get('DATA_ROOT', '/tmp/data')
167
- MODELS_DIR = os.path.join(DATA_ROOT, "models")
168
-
169
-
170
-
171
- async def return_image(image):
172
- res = await engine.load_image(data)
173
- id = res['u']
174
- webp_bytes = await engine.transform_image(res.get('uuid'), {
175
- "uuid": id,
176
- "params": {
177
- "aaa": -12,
178
- "eee": -12,
179
- "smile": -10,
180
- "woo": -6
181
- }
182
- })
183
-
184
- return webp_bytes
185
-
186
- async def setup():
187
- live_portrait = await initialize_models()
188
- engine = Engine(live_portrait=live_portrait)
189
- interface = gr.Interface(fn=return_image,
190
- inputs=gr.Image(type="filepath"),
191
- outputs=gr.Image(type="pil"),
192
- live=True,
193
- title="Retorno de Imagem")
194
- # Lançamento da interface
195
- interface.launch()
196
-
197
-
198
- if __name__ == "__main__":
199
- asyncio.run(setup())
 
1
+ import sys
2
  import asyncio
3
  from aiohttp import web, WSMsgType
4
  import json
 
130
  web.run_app(app, host="0.0.0.0", port=8080)
131
  except Exception as e:
132
  logger.critical(f"🚨 FATAL: Failed to start the app: {str(e)}")
133
+ logger.exception("Full traceback:")