K1Z3M1112 commited on
Commit
e774bc6
·
verified ·
1 Parent(s): ef930f3

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -578
app.py DELETED
@@ -1,578 +0,0 @@
1
- import os
2
- import gradio as gr
3
- import numpy as np
4
- import torch
5
- import random
6
- from PIL import Image, ImageEnhance, ImageFilter
7
- from gradio.themes import Soft
8
- from gradio.themes.utils import colors, fonts, sizes
9
-
10
- colors.steel_blue = colors.Color(
11
- name="steel_blue",
12
- c50="#EBF3F8",
13
- c100="#D3E5F0",
14
- c200="#A8CCE1",
15
- c300="#7DB3D2",
16
- c400="#529AC3",
17
- c500="#4682B4",
18
- c600="#3E72A0",
19
- c700="#36638C",
20
- c800="#2E5378",
21
- c900="#264364",
22
- c950="#1E3450",
23
- )
24
-
25
- class SteelBlueTheme(Soft):
26
- def __init__(self, **kwargs):
27
- super().__init__(
28
- primary_hue=colors.gray,
29
- secondary_hue=colors.steel_blue,
30
- neutral_hue=colors.slate,
31
- text_size=sizes.text_lg,
32
- font=(fonts.GoogleFont("Outfit"), "Arial", "sans-serif"),
33
- font_mono=(fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace"),
34
- )
35
-
36
- steel_blue_theme = SteelBlueTheme()
37
-
38
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
39
- dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
40
-
41
- print("=" * 50)
42
- print("🎨 LongCat Image-Edit Photo Restoration")
43
- print("=" * 50)
44
- print("Using device:", device)
45
- print("=" * 50)
46
-
47
- from diffusers import StableDiffusionXLImg2ImgPipeline
48
- import gc
49
-
50
- # Initialize model
51
- pipe = None
52
- model_name = None
53
-
54
- try:
55
- print("🔄 Loading LongCat-Image-Edit model...")
56
-
57
- # Load LongCat Image Edit model
58
- pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
59
- "meituan-longcat/LongCat-Image-Edit",
60
- torch_dtype=dtype,
61
- variant="fp16" if torch.cuda.is_available() else None,
62
- use_safetensors=True
63
- )
64
-
65
- model_name = "LongCat-Image-Edit"
66
- print(f"✅ Loaded {model_name}")
67
-
68
- pipe.to(device)
69
-
70
- # Enable memory optimizations
71
- print("⚡ Enabling optimizations...")
72
- if hasattr(pipe, 'enable_attention_slicing'):
73
- pipe.enable_attention_slicing(1)
74
- if hasattr(pipe, 'enable_vae_slicing'):
75
- pipe.enable_vae_slicing()
76
- if hasattr(pipe, 'enable_vae_tiling'):
77
- pipe.enable_vae_tiling()
78
-
79
- # Model offloading for better memory management
80
- if device.type == "cpu":
81
- print("💻 CPU mode - enabling model offloading")
82
- if hasattr(pipe, 'enable_model_cpu_offload'):
83
- pipe.enable_model_cpu_offload()
84
- else:
85
- print("🚀 GPU mode - enabling sequential CPU offload")
86
- if hasattr(pipe, 'enable_sequential_cpu_offload'):
87
- pipe.enable_sequential_cpu_offload()
88
-
89
- print(f"✅ Model ready: {model_name}")
90
-
91
- except Exception as e:
92
- print(f"❌ Error loading model: {e}")
93
-
94
- MAX_SEED = np.iinfo(np.int32).max
95
-
96
- # Enhanced restoration presets optimized for LongCat-Image-Edit
97
- RESTORATION_PRESETS = {
98
- "ลงสีภาพขาวดำ (Colorize)": {
99
- "prompt": "perfectly colorized vintage photograph, realistic natural colors, vibrant hues, accurate skin tones, professional photo restoration, historical accuracy, film photography aesthetic",
100
- "negative": "black and white, grayscale, monochrome, sepia, desaturated, washed out, artificial colors, oversaturated, cartoon",
101
- "strength": 0.75
102
- },
103
- "ซ่อมแซมเต็มรูปแบบ (Full Restore)": {
104
- "prompt": "pristine restored photograph, museum quality restoration, no damage, crystal clear details, vibrant accurate colors, professional archival restoration, perfect condition, high quality",
105
- "negative": "scratches, tears, stains, faded, damaged, low quality, blurry, artifacts, deteriorated, aged, noise",
106
- "strength": 0.70
107
- },
108
- "ลบรอยขีดข่วน (Remove Damage)": {
109
- "prompt": "clean photograph, flawless surface, no scratches, no tears, no stains, professionally restored, smooth perfect condition, pristine",
110
- "negative": "scratches, damage, tears, cracks, stains, spots, defects, deterioration, wear, marks",
111
- "strength": 0.60
112
- },
113
- "เพิ่มสีที่เลือนหาย (Enhance Faded)": {
114
- "prompt": "vibrant saturated colors, rich deep tones, enhanced contrast, vivid hues, color-corrected, professional color grading, cinema quality, perfect exposure",
115
- "negative": "faded, washed out, pale, dull colors, desaturated, flat, low contrast, muddy colors, underexposed",
116
- "strength": 0.55
117
- },
118
- "ลดสัญญาณรบกวน (Denoise)": {
119
- "prompt": "crystal clear photograph, ultra sharp details, noise-free, clean, high resolution 8k, professional quality, perfect clarity, no grain, smooth",
120
- "negative": "noisy, grainy, blurry, pixelated, low quality, compression artifacts, jpeg artifacts, soft, unclear",
121
- "strength": 0.50
122
- },
123
- "เพิ่มความคมชัด (Sharpen)": {
124
- "prompt": "ultra sharp photograph, crisp details, high definition, tack sharp focus, professional photography, 8k resolution, perfect clarity, detailed",
125
- "negative": "blurry, soft focus, out of focus, low resolution, hazy, unclear, motion blur, fuzzy",
126
- "strength": 0.45
127
- },
128
- "สไตล์โปรเฟสชันนัล (Pro Photo)": {
129
- "prompt": "professional studio photography, cinematic lighting, commercial quality, advertising photography, high-end fashion photography, vogue magazine style, perfect composition",
130
- "negative": "amateur, snapshot, casual photo, low quality, poor lighting, flat, unprofessional",
131
- "strength": 0.65
132
- },
133
- "สไตล์ภาพยนตร์ (Cinematic)": {
134
- "prompt": "cinematic film still, movie quality, dramatic lighting, film grain aesthetic, anamorphic lens, color graded, Hollywood production, cinematic look",
135
- "negative": "digital, flat, video game, animated, low budget, poor quality, amateur",
136
- "strength": 0.70
137
- },
138
- "เปลี่ยนเป็นอนิเมะ (Anime Style)": {
139
- "prompt": "beautiful anime art style, high quality manga illustration, studio ghibli quality, cel shaded, vibrant anime colors, detailed anime character, professional anime",
140
- "negative": "realistic, photographic, 3d render, western cartoon, ugly, bad anatomy, distorted",
141
- "strength": 0.85
142
- },
143
- "ภาพวาดสีน้ำ (Watercolor)": {
144
- "prompt": "beautiful watercolor painting, soft edges, artistic brushwork, traditional art medium, colorful artistic interpretation, fine art quality, watercolor texture",
145
- "negative": "photographic, digital art, sharp edges, realistic, computer generated, 3d",
146
- "strength": 0.80
147
- },
148
- "ภาพวาดน้ำมัน (Oil Painting)": {
149
- "prompt": "classical oil painting, renaissance style, visible brush strokes, artistic masterpiece, museum quality fine art, old master technique, rich colors",
150
- "negative": "photographic, digital, modern, flat colors, amateur, low quality, cartoon",
151
- "strength": 0.80
152
- },
153
- "กำหนดเอง (Custom)": {
154
- "prompt": "",
155
- "negative": "",
156
- "strength": 0.70
157
- }
158
- }
159
-
160
- def preprocess_image(image, enhance_quality=True):
161
- """Pre-process image for better results"""
162
- if enhance_quality:
163
- # Auto enhance
164
- enhancer = ImageEnhance.Sharpness(image)
165
- image = enhancer.enhance(1.2)
166
-
167
- enhancer = ImageEnhance.Contrast(image)
168
- image = enhancer.enhance(1.1)
169
-
170
- return image
171
-
172
- def restore_photo(
173
- input_image,
174
- preset_name,
175
- custom_prompt,
176
- custom_negative,
177
- strength,
178
- seed,
179
- randomize_seed,
180
- guidance_scale,
181
- steps,
182
- enhance_input,
183
- progress=gr.Progress(track_tqdm=True)
184
- ):
185
- """Enhanced image-to-image restoration with LongCat-Image-Edit"""
186
- if input_image is None:
187
- raise gr.Error("กรุณาอัพโหลดภาพ")
188
-
189
- if pipe is None:
190
- raise gr.Error("โมเดลยังไม่พร้อมใช้งาน")
191
-
192
- if randomize_seed:
193
- seed = random.randint(0, MAX_SEED)
194
-
195
- generator = torch.Generator(device=device).manual_seed(seed)
196
-
197
- # Get preset settings
198
- preset = RESTORATION_PRESETS[preset_name]
199
-
200
- # Use custom prompt if provided
201
- if custom_prompt.strip():
202
- prompt = custom_prompt
203
- negative_prompt = custom_negative if custom_negative.strip() else preset["negative"]
204
- denoising_strength = strength
205
- else:
206
- prompt = preset["prompt"]
207
- negative_prompt = preset["negative"]
208
- denoising_strength = preset["strength"]
209
-
210
- # Pre-process image
211
- original_image = input_image.convert("RGB")
212
- if enhance_input:
213
- original_image = preprocess_image(original_image)
214
-
215
- # Optimize size for processing
216
- width, height = original_image.size
217
-
218
- # LongCat works best at 1024x1024
219
- if device.type == "cpu":
220
- max_size = 768
221
- else:
222
- max_size = 1024
223
-
224
- if width > max_size or height > max_size:
225
- if width > height:
226
- new_width = max_size
227
- new_height = int(height * (max_size / width))
228
- else:
229
- new_height = max_size
230
- new_width = int(width * (max_size / height))
231
-
232
- # Make dimensions divisible by 8
233
- new_width = (new_width // 8) * 8
234
- new_height = (new_height // 8) * 8
235
- original_image = original_image.resize((new_width, new_height), Image.LANCZOS)
236
-
237
- try:
238
- # LongCat-Image-Edit generation
239
- result = pipe(
240
- prompt=prompt,
241
- negative_prompt=negative_prompt,
242
- image=original_image,
243
- strength=denoising_strength,
244
- guidance_scale=guidance_scale,
245
- num_inference_steps=steps,
246
- generator=generator,
247
- ).images[0]
248
-
249
- # Clean up memory
250
- if device.type == "cuda":
251
- torch.cuda.empty_cache()
252
- gc.collect()
253
-
254
- return result, seed
255
-
256
- except Exception as e:
257
- raise gr.Error(f"เกิดข้อผิดพลาด: {str(e)}")
258
-
259
- def update_preset_settings(preset_name):
260
- """Update UI when preset changes"""
261
- preset = RESTORATION_PRESETS[preset_name]
262
- return (
263
- preset["prompt"],
264
- preset["negative"],
265
- preset["strength"]
266
- )
267
-
268
- css="""
269
- #col-container {
270
- margin: 0 auto;
271
- max-width: 1400px;
272
- }
273
- #main-title h1 {
274
- font-size: 2.5em !important;
275
- text-align: center;
276
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
277
- -webkit-background-clip: text;
278
- -webkit-text-fill-color: transparent;
279
- background-clip: text;
280
- }
281
- .feature-box {
282
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
283
- color: white;
284
- border-radius: 12px;
285
- padding: 25px;
286
- margin: 20px 0;
287
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
288
- }
289
- .tip-box {
290
- background: #f0f7ff;
291
- border-left: 4px solid #4682B4;
292
- padding: 15px;
293
- margin: 15px 0;
294
- border-radius: 8px;
295
- }
296
- """
297
-
298
- with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
299
- with gr.Column(elem_id="col-container"):
300
- gr.Markdown("# 📸 Professional Photo Restoration", elem_id="main-title")
301
- gr.Markdown(f"### ✨ LongCat-Image-Edit • Professional Image Editing")
302
-
303
- gr.HTML(f"""
304
- <div class="feature-box">
305
- <h3>🚀 LongCat-Image-Edit Professional System</h3>
306
- <table style="width:100%; color:white; font-size:1.05em;">
307
- <tr>
308
- <td style="padding:8px;">⚡ <strong>Model:</strong></td>
309
- <td>LongCat-Image-Edit by Meituan</td>
310
- </tr>
311
- <tr>
312
- <td style="padding:8px;">🎯 <strong>Specialty:</strong></td>
313
- <td>Professional Image Editing & Restoration</td>
314
- </tr>
315
- <tr>
316
- <td style="padding:8px;">💎 <strong>Quality:</strong></td>
317
- <td>SDXL-based, optimized for editing tasks</td>
318
- </tr>
319
- <tr>
320
- <td style="padding:8px;">🎨 <strong>Features:</strong></td>
321
- <td>Better prompt following, precise edits</td>
322
- </tr>
323
- <tr>
324
- <td style="padding:8px;">💾 <strong>Memory:</strong></td>
325
- <td>Optimized with VAE tiling and attention slicing</td>
326
- </tr>
327
- </table>
328
- <div style="margin-top:15px; padding:10px; background:rgba(255,255,255,0.1); border-radius:8px;">
329
- <strong>🔬 LongCat Benefits:</strong><br>
330
- ✨ Better instruction following<br>
331
- 🎨 More accurate color restoration<br>
332
- 📐 Superior detail preservation<br>
333
- 💎 Specialized for image editing tasks
334
- </div>
335
- </div>
336
- """)
337
-
338
- with gr.Row(equal_height=True):
339
- with gr.Column(scale=1):
340
- input_image = gr.Image(
341
- label="📤 อัพโหลดภาพถ่ายเก่า",
342
- type="pil",
343
- height=420
344
- )
345
-
346
- gr.Markdown("### 🎯 เลือกรูปแบบการซ่อมแซม")
347
- preset = gr.Dropdown(
348
- choices=list(RESTORATION_PRESETS.keys()),
349
- label="เลือกพรีเซ็ต",
350
- value="ลงสีภาพขาวดำ (Colorize)",
351
- interactive=True
352
- )
353
-
354
- custom_prompt = gr.Textbox(
355
- label="💬 Prompt (คำสั่งบวก)",
356
- placeholder="อธิบายผลลัพธ์ที่ต้องการ...",
357
- lines=2,
358
- value=RESTORATION_PRESETS["ลงสีภาพขาวดำ (Colorize)"]["prompt"]
359
- )
360
-
361
- custom_negative = gr.Textbox(
362
- label="🚫 Negative Prompt (สิ่งที่ไม่ต้องการ)",
363
- placeholder="อธิบายสิ่งที่ไม่ต้องการ...",
364
- lines=2,
365
- value=RESTORATION_PRESETS["ลงสีภาพขาวดำ (Colorize)"]["negative"]
366
- )
367
-
368
- preset.change(
369
- fn=update_preset_settings,
370
- inputs=[preset],
371
- outputs=[custom_prompt, custom_negative, gr.Slider()]
372
- )
373
-
374
- run_button = gr.Button("✨ เริ่มซ่อมแซมภาพ", variant="primary", size="lg")
375
-
376
- with gr.Column(scale=1):
377
- output_image = gr.Image(
378
- label="✨ ภาพที่ซ่อมแซมแล้ว",
379
- interactive=False,
380
- format="png",
381
- height=540
382
- )
383
-
384
- with gr.Accordion("⚙️ การตั้งค่าขั้นสูง", open=True):
385
- strength = gr.Slider(
386
- label="💪 Denoising Strength",
387
- minimum=0.1,
388
- maximum=1.0,
389
- step=0.05,
390
- value=0.75,
391
- info="0.3-0.5: เปลี่ยนน้อย | 0.6-0.7: สมดุล | 0.8+: เปลี่ยนมาก"
392
- )
393
-
394
- seed = gr.Slider(
395
- label="🎲 Seed",
396
- minimum=0,
397
- maximum=MAX_SEED,
398
- step=1,
399
- value=42,
400
- info="ใช้ seed เดิมได้ผลลัพธ์เหมือนเดิม"
401
- )
402
-
403
- randomize_seed = gr.Checkbox(
404
- label="🔀 สุ่ม Seed ทุกครั้ง",
405
- value=True
406
- )
407
-
408
- guidance_scale = gr.Slider(
409
- label="💬 Guidance Scale",
410
- minimum=1.0,
411
- maximum=15.0,
412
- step=0.5,
413
- value=7.5,
414
- info="ยิ่งสูง = ทำตามคำสั่งมากขึ้น"
415
- )
416
-
417
- steps = gr.Slider(
418
- label="🔢 Inference Steps",
419
- minimum=10,
420
- maximum=50,
421
- step=5,
422
- value=30,
423
- info="LongCat: 25-35 แนะนำ | 40-50 คุณภาพสูงสุด"
424
- )
425
-
426
- enhance_input = gr.Checkbox(
427
- label="✨ ปรับปรุงภาพอินพุตอัตโนมัติ",
428
- value=True,
429
- info="เพิ่มความคมชัดและคอนทราสต์"
430
- )
431
-
432
- gr.HTML("""
433
- <div class="tip-box">
434
- <strong>💡 คำแนะนำ LongCat-Image-Edit:</strong><br>
435
- • <strong>Strength 0.4-0.6:</strong> แก้ไขเล็กน้อย<br>
436
- • <strong>Strength 0.7-0.8:</strong> แก้ไขปานกลาง ✅<br>
437
- • <strong>Strength 0.85+:</strong> เปลี่ยนแปลงมาก<br><br>
438
- • <strong>Guidance 7-9:</strong> สมดุลดี ✅<br>
439
- • <strong>Steps 25-35:</strong> คุณภาพดี<br>
440
- • <strong>Steps 40-50:</strong> คุณภาพสูงสุด
441
- </div>
442
- """)
443
-
444
- # Update strength when preset changes
445
- preset.change(
446
- fn=lambda x: RESTORATION_PRESETS[x]["strength"],
447
- inputs=[preset],
448
- outputs=[strength]
449
- )
450
-
451
- run_button.click(
452
- fn=restore_photo,
453
- inputs=[
454
- input_image, preset, custom_prompt, custom_negative,
455
- strength, seed, randomize_seed, guidance_scale,
456
- steps, enhance_input
457
- ],
458
- outputs=[output_image, seed]
459
- )
460
-
461
- gr.Markdown(f"""
462
- ---
463
- ### 📚 คู่มือการใช้งาน LongCat-Image-Edit Professional
464
-
465
- #### 🚀 **ทำไมต้อง LongCat-Image-Edit?**
466
-
467
- **จุดเด่น:**
468
- - ✅ **ออกแบบเฉพาะทาง** - เน้นการแก้ไขและปรับปรุงภาพโดยเฉพาะ
469
- - ✅ **SDXL-based** - ใช้พื้นฐาน SDXL คุณภาพสูง
470
- - ✅ **Better Following** - ทำตามคำสั่งได้แม่นยำกว่า
471
- - ✅ **Precise Editing** - แก้ไขจุดเฉพาะได้ดีเยี่ยม
472
- - ✅ **Natural Results** - ผลลัพธ์ดูเป็นธรรมชาติ
473
- - ✅ **Flexible Strength** - ปรับระดับการแก้ไขได้ละเอียด
474
-
475
- **เหมาะกับ:**
476
- - 🎨 การลงสีภาพขาวดำ
477
- - 🔧 การซ่อมแซมภาพเก่า
478
- - ✨ การปรับปรุงคุณภาพภาพ
479
- - 🎭 การเปลี่ยนสไตล์ภาพ
480
- - 📸 การทำ Photo Enhancement
481
-
482
- #### 🎯 **วิธีใช้งาน:**
483
-
484
- 1. **อัพโหลดภาพ** ที่ต้องการแก้ไข
485
- 2. **เลือกพรีเซ็ต** - มี 12 รูปแบบให้เลือก
486
- 3. **ปรับ Strength** ตามความต้องการ (0.7-0.8 แนะนำ)
487
- 4. **เปิด Input Enhancement** สำหรับผลลัพธ์ดีขึ้น
488
- 5. **กดปุ่ม "เริ่มซ่อมแซมภาพ"**
489
- 6. **รอ 1-3 นาที** (ขึ้นกับฮาร์ดแวร์)
490
-
491
- #### ⚙️ **การตั้งค่าที่แนะนำ:**
492
-
493
- | งาน | Strength | Guidance | Steps |
494
- |-----|----------|----------|-------|
495
- | ลงสีภาพขาวดำ | 0.75 | 7-8 | 30 |
496
- | ซ่อมแซมรอยขีดข่วน | 0.60 | 6-7 | 25-30 |
497
- | เพิ่มความคมชัด | 0.45 | 5-6 | 25 |
498
- | เปลี่ยนสไตล์ | 0.80-0.85 | 8-10 | 30-40 |
499
- | คุณภาพสูงสุด | 0.70 | 7-9 | 40-50 |
500
-
501
- #### 💡 **เคล็ดลับ:**
502
-
503
- **สำหรับ CPU:**
504
- - ใช้ Steps 20-25
505
- - Guidance 6-7
506
- - Strength 0.6-0.7
507
- - ภาพไม่เกิน 768x768px
508
- - Expected: 2-4 นาที/ภาพ
509
-
510
- **สำหรับ GPU (8GB+):**
511
- - ใช้ Steps 30-40
512
- - Guidance 7-9
513
- - ภาพได้ถึง 1024x1024px
514
- - Expected: 30-60 วินาที/ภาพ
515
-
516
- **สำหรับ GPU (16GB+):**
517
- - ใช้ Steps 40-50
518
- - Guidance 8-10
519
- - ความละเอียดสูงสุด
520
- - Expected: 20-45 วินาที/ภาพ
521
-
522
- #### 📊 **พรีเซ็ตทั้งหมด:**
523
-
524
- - 🎨 **ลงสีภาพขาวดำ** - แปลงภาพขาวดำเป็นสีสมจริง
525
- - 🔧 **ซ่อมแซมเต็มรูปแบบ** - ลบรอยชำรุด ปรับปรุงคุณภาพ
526
- - 🧹 **ลบรอยขีดข่วน** - กำจัดรอยเสียหาย
527
- - 💎 **เพิ่มสีที่เลือนหาย** - ทำให้สีสดใสขึ้น
528
- - 📐 **ลดสัญญาณรบกวน** - ลดเกรน เพิ่มความคมชัด
529
- - ✨ **เพิ่มความคมชัด** - ทำให้ภาพคมชัดขึ้น
530
- - 📸 **สไตล์โปรเฟสชันนัล** - แปลงเป็นภาพถ่ายสตูดิโอ
531
- - 🎬 **สไตล์ภาพยนตร์** - ให้ความรู้สึกแบบหนัง
532
- - 🎭 **เปลี่ยนเป็นอนิเมะ** - แปลงเป็นสไตล์อนิเมะ
533
- - 🖼️ **ภาพวาดสีน้ำ** - แปลงเป็นภาพวาดสีน้ำ
534
- - 🎨 **ภาพวาดน้ำมัน** - แปลงเป็นภาพวาดน้ำมัน
535
- - ⚙️ **กำหนดเอง** - ปรับแต่งเองได้ทุกอย่าง
536
-
537
- #### ⚡ **ประสิทธิภาพ:**
538
-
539
- **LongCat-Image-Edit Performance:**
540
- - **CPU (16GB RAM):** 2-4 นาที/ภาพ (768px)
541
- - **GPU (8GB VRAM):** 30-60 วินาที/ภาพ (1024px)
542
- - **GPU (12GB VRAM):** 25-50 วินาที/ภาพ (1024px)
543
- - **GPU (16GB+ VRAM):** 20-45 วินาที/ภาพ (1024px)
544
-
545
- **ขนาดโมเดล:**
546
- - LongCat-Image-Edit: ~6.5GB
547
- - Total: ~6.5GB
548
-
549
- #### 🎯 **Use Cases:**
550
-
551
- ✅ **เหมาะสำหรับ:**
552
- - ภาพถ่ายโบราณที่ต้องการซ่อมแซม
553
- - ภาพที่ต้องการลงสี
554
- - ภาพที่ต้องการแก้ไขเฉพาะจุด
555
- - การปรับปรุงคุณภาพภาพ
556
- - การเปลี่ยนสไตล์ภาพ
557
- - งาน Professional Photo Editing
558
-
559
- ⚠️ **ข้อควรระวัง:**
560
- - ต้องการ RAM/VRAM อย่างน้อย 8GB
561
- - Strength สูงเกินไปอาจทำให้ภาพเปลี่ยนมาก
562
- - ควร resize ภาพก่อนถ้าขนาดใหญ่มาก
563
-
564
- #### 💡 **Tips & Tricks:**
565
-
566
- **1. การเลือก Strength:**
567
- - 0.4-0.6: แก้ไขเล็กน้อย (ลดสัญญาณรบกวน)
568
- - 0.7-0.8: แก้ไขปานกลาง (แนะนำ) ✅
569
- - 0.85-0.95: เปลี่ยนแปลงมาก (เปลี่ยนสไตล์)
570
-
571
- **2. ปรับปรุงคุณภาพ:**
572
- - เปิ
573
-
574
- ---
575
- """)
576
-
577
- if __name__ == "__main__":
578
- demo.launch(server_name="0.0.0.0", server_port=7860, share=False)