Akjava commited on
Commit
469d515
1 Parent(s): 397db89

add example

Browse files
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import re
4
  from PIL import Image
5
  import flux1_inpaint
6
-
7
 
8
  def sanitize_prompt(prompt):
9
  # Allow only alphanumeric characters, spaces, and basic punctuation
@@ -43,6 +43,14 @@ def read_file(path: str) -> str:
43
 
44
  return content
45
 
 
 
 
 
 
 
 
 
46
  css="""
47
  #col-left {
48
  margin: 0 auto;
@@ -76,24 +84,24 @@ with demo_blocks as demo:
76
 
77
 
78
  with gr.Column():
79
- image_out = gr.Image(height=800,sources=[],label="Output", elem_id="output-img")
 
 
80
 
81
 
82
 
83
  btn.click(fn=process_images, inputs=[image, image_mask,prompt,inpaint_model,strength,seed], outputs =image_out, api_name='infer')
84
  gr.Examples(
85
- examples=[["examples/catman.jpg", "examples/catman_mask.jpg","He's wearing a dog face."]]
86
  ,
87
- #fn=predict,
88
- inputs=[image,image_mask,prompt],
89
- cache_examples=False,
 
90
  )
91
  gr.HTML(
92
  """
93
- <div style="text-align: center;">
94
- <p>Inpaint Code <a href="https://github.com/opencv/opencv/blob/da3debda6d233af90e421e95700c63fc08b83b75/samples/python/inpaint.py" style="text-decoration: underline;" target="_blank">OpenCV inpaint example</a> - Gradio Demo by 🤗 Hugging Face
95
- </p>
96
- </div>
97
  """
98
  )
99
 
 
3
  import re
4
  from PIL import Image
5
  import flux1_inpaint
6
+ import os
7
 
8
  def sanitize_prompt(prompt):
9
  # Allow only alphanumeric characters, spaces, and basic punctuation
 
43
 
44
  return content
45
 
46
+ def example_out(image,image_mask,prompt,strength,example_id):
47
+ # input
48
+ #parent,file=os.path.split(image_mask) # image is complex dict
49
+ #base,ext = os.path.splitext(file)
50
+ #key = base.split("_")[0]
51
+
52
+ return f"images/{example_id}.jpg"
53
+
54
  css="""
55
  #col-left {
56
  margin: 0 auto;
 
84
 
85
 
86
  with gr.Column():
87
+ id_input=gr.Text(label="Name", visible=False)
88
+ image_out = gr.Image(height=800,sources=[],label="Output", elem_id="output-img",format="jpeg")
89
+
90
 
91
 
92
 
93
  btn.click(fn=process_images, inputs=[image, image_mask,prompt,inpaint_model,strength,seed], outputs =image_out, api_name='infer')
94
  gr.Examples(
95
+ examples=[["images/00207245_18.jpg", "images/00207245_18_mask.jpg","a beautiful girl,mouth opened",0.3,"00207245"]]
96
  ,
97
+ fn=example_out,
98
+ inputs=[image,image_mask,prompt,strength,id_input],
99
+ outputs=[image_out],
100
+ cache_examples=True,
101
  )
102
  gr.HTML(
103
  """
104
+
 
 
 
105
  """
106
  )
107
 
images/00207245.jpg ADDED
images/00207245_18.jpg ADDED
images/00207245_18_mask.jpg ADDED
images/00538245.webp ADDED
images/00538245_mask.jpg ADDED
images/00538245_paint.jpg ADDED
images/00547245.webp ADDED
images/00547245_99.jpg ADDED
images/00547245_99_mask.jpg ADDED