Nekochu commited on
Commit
63873ef
·
verified ·
1 Parent(s): e9fafb5
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +52 -5
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: "SD Dataset Automaker: Fancaps → YOLO → Siamese → WD Tag → ZIP"
3
  emoji: 🎴💆📦
4
  colorFrom: indigo
5
  colorTo: pink
@@ -96,4 +96,4 @@ print(f"ZIP: {zip_path}")
96
  </details>
97
 
98
  ---
99
- *CPU runtime ~5-10 min*
 
1
  ---
2
+ title: "SD Dataset Automaker: Fancaps → Face Crop (YOLO)Similarity (Siamese) → WD Tagger → ZIP"
3
  emoji: 🎴💆📦
4
  colorFrom: indigo
5
  colorTo: pink
 
96
  </details>
97
 
98
  ---
99
+ *CPU runtime ~5-10 min* | Based on [Maximax67/LoRA-Dataset-Automaker](https://github.com/Maximax67/LoRA-Dataset-Automaker)
app.py CHANGED
@@ -536,8 +536,8 @@ css = """
536
  .compact-group { margin-bottom: 8px !important; }
537
  """
538
 
539
- with gr.Blocks(title="SD Dataset Automaker: Fancaps → YOLO → Siamese → WD Tag → ZIP") as demo:
540
- gr.Markdown("### SD Dataset Automaker: Fancaps → YOLO → Siamese → WD → ZIP")
541
 
542
  with gr.Row():
543
  with gr.Column(scale=3):
@@ -623,6 +623,49 @@ with gr.Blocks(title="SD Dataset Automaker: Fancaps → YOLO → Siamese → WD
623
 
624
  run_btn.click(process, [query, char, ref_imgs, ref_files, max_img, thresh, act_tag, anime_cb, movies_cb, tv_cb], [out_file, out_log])
625
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
  def run_cli():
627
  """CLI mode with cloudscraper for Cloudflare bypass"""
628
  # Use cloudscraper for CLI (bypasses Cloudflare on local/residential IPs)
@@ -680,13 +723,17 @@ if __name__ == "__main__":
680
  if len(sys.argv) > 1:
681
  run_cli()
682
  else:
683
- # Gradio UI mode
684
  allowed_dir = os.path.dirname(os.path.abspath(__file__))
685
- demo.launch(
 
 
 
 
 
686
  server_name="0.0.0.0",
687
  server_port=7860,
688
  mcp_server=True,
689
  show_error=True,
690
  allowed_paths=[allowed_dir],
691
- css=css,
692
  )
 
536
  .compact-group { margin-bottom: 8px !important; }
537
  """
538
 
539
+ with gr.Blocks(title="SD Dataset Automaker: Fancaps → Face Crop (YOLO)Similarity (Siamese) → WD Tagger → ZIP") as demo:
540
+ gr.Markdown("### SD Dataset Automaker: Fancaps → Face Crop (YOLO)Similarity (Siamese) → WD Tagger → ZIP")
541
 
542
  with gr.Row():
543
  with gr.Column(scale=3):
 
623
 
624
  run_btn.click(process, [query, char, ref_imgs, ref_files, max_img, thresh, act_tag, anime_cb, movies_cb, tv_cb], [out_file, out_log])
625
 
626
+ # MCP-only function (no Gallery - avoids $ref schema bug)
627
+ def create_dataset(url: str, character: str, reference_images, max_images: int = 200, similarity_threshold: int = 32, trigger_tag: str = ""):
628
+ """Create anime character dataset for LoRA/SD training.
629
+
630
+ Args:
631
+ url: Fancaps.net URL (e.g. https://fancaps.net/anime/showimages.php?3092-Cowboy_Bebop)
632
+ character: Character name for tagging (e.g. spike_spiegel)
633
+ reference_images: 1-5 face reference images of target character
634
+ max_images: Maximum frames to download (50-500)
635
+ similarity_threshold: Face matching threshold, lower=stricter (25-40, default 32)
636
+ trigger_tag: Optional trigger word to prepend to captions
637
+
638
+ Returns:
639
+ Tuple of (zip_file_path, log_text)
640
+ """
641
+ paths = []
642
+ if reference_images:
643
+ for f in (reference_images if isinstance(reference_images, list) else [reference_images]):
644
+ fp = f.name if hasattr(f, 'name') else str(f)
645
+ if fp and os.path.exists(fp): paths.append(fp)
646
+ if not paths:
647
+ return None, "ERROR: No reference images provided. Upload 1-5 face images."
648
+ if not url or 'fancaps.net' not in url:
649
+ return None, "ERROR: Invalid URL. Provide a fancaps.net URL."
650
+ zp, log = run(url, character, paths, max_images, similarity_threshold, trigger_tag, True, False, False, None)
651
+ return zp, log
652
+
653
+ # Create MCP interface (File input only - no Gallery)
654
+ mcp_interface = gr.Interface(
655
+ fn=create_dataset,
656
+ inputs=[
657
+ gr.Textbox(label="Fancaps URL"),
658
+ gr.Textbox(label="Character Name"),
659
+ gr.File(label="Reference Images", file_count="multiple", file_types=["image"]),
660
+ gr.Slider(50, 500, 200, step=50, label="Max Images"),
661
+ gr.Slider(25, 40, 32, step=1, label="Similarity Threshold"),
662
+ gr.Textbox(label="Trigger Tag"),
663
+ ],
664
+ outputs=[gr.File(label="Dataset ZIP"), gr.Textbox(label="Log")],
665
+ api_name="create_dataset",
666
+ title="SD Dataset Automaker (MCP)",
667
+ )
668
+
669
  def run_cli():
670
  """CLI mode with cloudscraper for Cloudflare bypass"""
671
  # Use cloudscraper for CLI (bypasses Cloudflare on local/residential IPs)
 
723
  if len(sys.argv) > 1:
724
  run_cli()
725
  else:
726
+ # Gradio UI mode - combine main UI and MCP interface
727
  allowed_dir = os.path.dirname(os.path.abspath(__file__))
728
+ app = gr.TabbedInterface(
729
+ [demo, mcp_interface],
730
+ ["Dataset Maker", "MCP API"],
731
+ title="SD Dataset Automaker"
732
+ )
733
+ app.launch(
734
  server_name="0.0.0.0",
735
  server_port=7860,
736
  mcp_server=True,
737
  show_error=True,
738
  allowed_paths=[allowed_dir],
 
739
  )