TDN-M commited on
Commit
25b71ab
·
verified ·
1 Parent(s): cd8bf38

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -6
main.py CHANGED
@@ -17,18 +17,15 @@ groq_api_key = os.getenv('groq_api_key', '')
17
  if not api_key_token or not groq_api_key:
18
  raise ValueError("Please configure your API keys in .env")
19
 
20
- # Lưu trữ phương thức __init__ gốc của Groq
21
  original_init = Groq.__init__
22
 
23
- # Định nghĩa phương thức khởi tạo mới
24
  def patched_init(self, *args, **kwargs):
25
  kwargs.pop("proxies", None) # Loại bỏ tham số proxies nếu có
26
  original_init(self, *args, **kwargs)
27
 
28
- # Ghi đè phương thức __init__ của Groq
29
  Groq.__init__ = patched_init
30
 
31
- # Khởi tạo client Groq
32
  client = Groq(api_key=groq_api_key)
33
 
34
  # Cấu hình cơ bản
@@ -193,7 +190,7 @@ def generate_mask(image_resource_id, position, selected_product_code):
193
  time.sleep(10)
194
 
195
  workflow_params = {
196
- "1": {"classType": "LayerMask: SegmentAnythingUltra V3", "inputs": {"image": ["2", 0], "prompt": ["4", 0]}},
197
  "2": {"classType": "TensorArt_LoadImage", "inputs": {"image": image_resource_id}},
198
  "4": {"classType": "TensorArt_PromptText", "inputs": {"Text": position.lower()}},
199
  "17": {"classType": "TensorArt_LoadImage", "inputs": {"image": texture_resource_id}},
@@ -270,7 +267,7 @@ def api_img2img(file, position, size, custom_size, product_codes):
270
 
271
  # Giao diện Gradio (tùy chọn)
272
  with gr.Blocks() as demo:
273
- gr.Markdown("## Backend Gradio cho CaslaQuartz")
274
  gr.Interface(fn=lambda x: "API only", inputs="text", outputs="text")
275
 
276
  # Khởi chạy Gradio với API
 
17
  if not api_key_token or not groq_api_key:
18
  raise ValueError("Please configure your API keys in .env")
19
 
20
+ # Khởi tạo client Groq (sửa lỗi proxies)
21
  original_init = Groq.__init__
22
 
 
23
  def patched_init(self, *args, **kwargs):
24
  kwargs.pop("proxies", None) # Loại bỏ tham số proxies nếu có
25
  original_init(self, *args, **kwargs)
26
 
 
27
  Groq.__init__ = patched_init
28
 
 
29
  client = Groq(api_key=groq_api_key)
30
 
31
  # Cấu hình cơ bản
 
190
  time.sleep(10)
191
 
192
  workflow_params = {
193
+ "1": { "classType": "LayerMask: SegmentAnythingUltra V3", "inputs": {"image": ["2", 0], "prompt": ["4", 0]}},
194
  "2": {"classType": "TensorArt_LoadImage", "inputs": {"image": image_resource_id}},
195
  "4": {"classType": "TensorArt_PromptText", "inputs": {"Text": position.lower()}},
196
  "17": {"classType": "TensorArt_LoadImage", "inputs": {"image": texture_resource_id}},
 
267
 
268
  # Giao diện Gradio (tùy chọn)
269
  with gr.Blocks() as demo:
270
+ gr.Markdown("## Backend Gradio cho CaslaQuartz")
271
  gr.Interface(fn=lambda x: "API only", inputs="text", outputs="text")
272
 
273
  # Khởi chạy Gradio với API