Bingsu commited on
Commit
9e1a19f
β€’
1 Parent(s): 1c4c40f

feat: info, fix mkdir error, bottom download button

Browse files
Files changed (2) hide show
  1. app.py +10 -0
  2. info.txt +7 -0
app.py CHANGED
@@ -18,6 +18,14 @@ def hex_to_rgb(s: str) -> tuple[int, int, int]:
18
  return (int(value[:2], 16), int(value[2:4], 16), int(value[4:6], 16))
19
 
20
 
 
 
 
 
 
 
 
 
21
  col1, col2 = st.columns([15, 85])
22
  color = col1.color_picker("Pick a color", "#00f900")
23
  col2.text_input("", color, disabled=True)
@@ -38,6 +46,7 @@ if output_path.exists():
38
  shutil.rmtree(output_path)
39
 
40
  dataset_path.mkdir()
 
41
  img_path = dataset_path / f"{emb_name}.png"
42
  Image.fromarray(img_array).save(img_path)
43
 
@@ -115,3 +124,4 @@ torch.save(trained_emb, result_path)
115
 
116
  file = result_path.read_bytes()
117
  download_button.download_button(f"Download {emb_name}.pt", file, f"{emb_name}.pt")
 
 
18
  return (int(value[:2], 16), int(value[2:4], 16), int(value[4:6], 16))
19
 
20
 
21
+ st.header("Color Textual Inversion")
22
+ with st.expander(label="info"):
23
+ with open("info.txt", "r", encoding="utf-8") as f:
24
+ st.markdown(f.read())
25
+
26
+ duplicate_button = """<a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/Bingsu/color_textual_inversion?duplicate=true"><img style="margin: 0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>"""
27
+ st.markdown(duplicate_button, unsafe_allow_html=True)
28
+
29
  col1, col2 = st.columns([15, 85])
30
  color = col1.color_picker("Pick a color", "#00f900")
31
  col2.text_input("", color, disabled=True)
 
46
  shutil.rmtree(output_path)
47
 
48
  dataset_path.mkdir()
49
+ output_path.mkdir()
50
  img_path = dataset_path / f"{emb_name}.png"
51
  Image.fromarray(img_array).save(img_path)
52
 
 
124
 
125
  file = result_path.read_bytes()
126
  download_button.download_button(f"Download {emb_name}.pt", file, f"{emb_name}.pt")
127
+ st.download_button(f"Download {emb_name}.pt ", file, f"{emb_name}.pt")
info.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ Create an embedding that represents a color code.
2
+
3
+ Using only one simple color image, textual inversion training is performed.
4
+
5
+ This idea is from the arcalive AI image channel, [λ‚΄κ°€ μ›ν•˜λŠ” μƒ‰μƒμ½”λ“œλ₯Ό λ§Œλ“€μ–΄ μ‚¬μš©ν•΄ 보자](https://arca.live/b/aiart/64702219).
6
+
7
+ However, this space uses an implementation of huggingface diffusers, so the result is different from webui. Please be careful on this point.