remove examples add read content
Browse files
app.py
CHANGED
@@ -26,6 +26,14 @@ transform = transforms.Compose([
|
|
26 |
transforms.Resize((512, 512)),
|
27 |
])
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def predict(dict, prompt=""):
|
30 |
with autocast("cuda"):
|
31 |
init_image = dict["image"].convert("RGB").resize((512, 512))
|
@@ -33,7 +41,6 @@ def predict(dict, prompt=""):
|
|
33 |
output = pipe(prompt = prompt, image=init_image, mask_image=mask, strength=0.8,num_inference_steps=20)
|
34 |
return output.images[0]
|
35 |
|
36 |
-
examples = [[dict(image="init_image.png", mask="mask_image.png"), "A panda sitting on a bench"]]
|
37 |
|
38 |
css = '''
|
39 |
.container {max-width: 1150px;margin: auto;padding-top: 1.5rem}
|
@@ -64,8 +71,7 @@ with image_blocks as demo:
|
|
64 |
rounded=(False, True, True, False),
|
65 |
full_width=False,
|
66 |
)
|
67 |
-
|
68 |
-
ex.dataset.headers = [""]
|
69 |
btn.click(fn=predict, inputs=[image, prompt], outputs=image)
|
70 |
|
71 |
|
|
|
26 |
transforms.Resize((512, 512)),
|
27 |
])
|
28 |
|
29 |
+
def read_content(file_path: str) -> str:
|
30 |
+
"""read the content of target file
|
31 |
+
"""
|
32 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
33 |
+
content = f.read()
|
34 |
+
|
35 |
+
return content
|
36 |
+
|
37 |
def predict(dict, prompt=""):
|
38 |
with autocast("cuda"):
|
39 |
init_image = dict["image"].convert("RGB").resize((512, 512))
|
|
|
41 |
output = pipe(prompt = prompt, image=init_image, mask_image=mask, strength=0.8,num_inference_steps=20)
|
42 |
return output.images[0]
|
43 |
|
|
|
44 |
|
45 |
css = '''
|
46 |
.container {max-width: 1150px;margin: auto;padding-top: 1.5rem}
|
|
|
71 |
rounded=(False, True, True, False),
|
72 |
full_width=False,
|
73 |
)
|
74 |
+
|
|
|
75 |
btn.click(fn=predict, inputs=[image, prompt], outputs=image)
|
76 |
|
77 |
|