Spaces:
Runtime error
Runtime error
initial
Browse files- app.py +252 -0
- editings_table.csv +36 -0
- images/gosling.jpg +0 -0
- images/robert.png +0 -0
- images/scarlet.jpg +0 -0
- images/smith.jpg +0 -0
- images/watson.jpeg +0 -0
- inference_pb2.py +34 -0
- inference_pb2_grpc.py +145 -0
- requirements.txt +7 -0
app.py
ADDED
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from io import BytesIO
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import grpc
|
6 |
+
from PIL import Image
|
7 |
+
import pandas as pd
|
8 |
+
|
9 |
+
from inference_pb2 import SFERequest, SFEResponse, SFERequestMask, SFEResponseMask
|
10 |
+
from inference_pb2_grpc import SFEServiceStub
|
11 |
+
|
12 |
+
PREDEFINED_EDITINGS_LIST = [
|
13 |
+
"glasses",
|
14 |
+
"smile",
|
15 |
+
"makeup",
|
16 |
+
"eye_openness",
|
17 |
+
"trimmed_beard",
|
18 |
+
"lipstick",
|
19 |
+
"face_roundness",
|
20 |
+
"nose_length",
|
21 |
+
"eyebrow_thickness",
|
22 |
+
"displeased",
|
23 |
+
"age",
|
24 |
+
"rotation",
|
25 |
+
"afro",
|
26 |
+
"angry",
|
27 |
+
"bobcut",
|
28 |
+
"bowlcut",
|
29 |
+
"mohawk",
|
30 |
+
"curly_hair",
|
31 |
+
"purple_hair",
|
32 |
+
"surprised",
|
33 |
+
"beyonce",
|
34 |
+
"hilary_clinton",
|
35 |
+
"depp",
|
36 |
+
"taylor_swift",
|
37 |
+
"trump",
|
38 |
+
"zuckerberg",
|
39 |
+
"black hair",
|
40 |
+
"blond hair",
|
41 |
+
"grey hair",
|
42 |
+
"wavy hair",
|
43 |
+
"receding hairline",
|
44 |
+
"sideburns",
|
45 |
+
"goatee",
|
46 |
+
"earrings",
|
47 |
+
"gender"
|
48 |
+
]
|
49 |
+
|
50 |
+
DIRECTIONS_NAME_SWAP = {
|
51 |
+
"smile" : "fs_smiling",
|
52 |
+
"glasses": "fs_glasses",
|
53 |
+
"makeup": "fs_makeup",
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
def get_bytes(img):
|
58 |
+
if img is None:
|
59 |
+
return img
|
60 |
+
|
61 |
+
buffered = BytesIO()
|
62 |
+
img.save(buffered, format="JPEG")
|
63 |
+
return buffered.getvalue()
|
64 |
+
|
65 |
+
|
66 |
+
def bytes_to_image(image: bytes) -> Image.Image:
|
67 |
+
image = Image.open(BytesIO(image))
|
68 |
+
return image
|
69 |
+
|
70 |
+
|
71 |
+
def edit_image(orig_image, edit_direction, edit_power, align, mask, progress=gr.Progress(track_tqdm=True)):
|
72 |
+
if edit_direction in DIRECTIONS_NAME_SWAP:
|
73 |
+
edit_direction = DIRECTIONS_NAME_SWAP[edit_direction]
|
74 |
+
if not orig_image:
|
75 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(value="Need to upload an input image ❗", visible=True)
|
76 |
+
|
77 |
+
orig_image_bytes = get_bytes(orig_image)
|
78 |
+
mask_bytes = get_bytes(mask)
|
79 |
+
if mask_bytes is None:
|
80 |
+
mask_bytes = b"mask"
|
81 |
+
|
82 |
+
with grpc.insecure_channel(os.environ['SERVER']) as channel:
|
83 |
+
stub = SFEServiceStub(channel)
|
84 |
+
|
85 |
+
output: SFEResponse = stub.edit(
|
86 |
+
SFERequest(orig_image=orig_image_bytes, direction=edit_direction, power=edit_power, align=align, mask=mask_bytes, use_cache=True)
|
87 |
+
)
|
88 |
+
|
89 |
+
if output.image == b"aligner error":
|
90 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(value="Face aligner can not find face in your image 😢 Try to upload another one", visible=True)
|
91 |
+
|
92 |
+
output_edited = bytes_to_image(output.image)
|
93 |
+
output_inv = bytes_to_image(output.inv_image)
|
94 |
+
return gr.update(value=output_edited, visible=True), gr.update(value=output_inv, visible=True), gr.update(visible=False)
|
95 |
+
|
96 |
+
|
97 |
+
def edit_image_clip(orig_image, neutral_prompt, target_prompt, disentanglement, edit_power, align, mask, progress=gr.Progress(track_tqdm=True)):
|
98 |
+
edit_direction = "_".join(["styleclip_global", neutral_prompt, target_prompt, str(disentanglement)])
|
99 |
+
return edit_image(orig_image, edit_direction, edit_power, align, mask, progress=None)
|
100 |
+
|
101 |
+
|
102 |
+
def get_mask(input_image, align, mask_trashhold, progress=gr.Progress(track_tqdm=True)):
|
103 |
+
if not input_image:
|
104 |
+
return gr.update(visible=False), gr.update(value="Need to upload an input image ❗", visible=True)
|
105 |
+
|
106 |
+
input_image_bytes = get_bytes(input_image)
|
107 |
+
|
108 |
+
with grpc.insecure_channel(os.environ['SERVER']) as channel:
|
109 |
+
stub = SFEServiceStub(channel)
|
110 |
+
|
111 |
+
output: SFEResponseMask = stub.generate_mask(
|
112 |
+
SFERequestMask(orig_image=input_image_bytes, trashold=mask_trashhold, align=align, use_cache=True)
|
113 |
+
)
|
114 |
+
if output.mask == b"aligner error":
|
115 |
+
return gr.update(visible=False), gr.update(value="Face aligner can not find face in your image 😢 Try to upload another one", visible=True)
|
116 |
+
|
117 |
+
if output.mask == b"masker face parser error":
|
118 |
+
return gr.update(visible=False), gr.update(value="Masker's face detector can't find face in your image 😢 Try to upload another one", visible=True)
|
119 |
+
|
120 |
+
output_mask = bytes_to_image(output.mask)
|
121 |
+
return gr.update(value=output_mask, visible=True), gr.update(visible=False)
|
122 |
+
|
123 |
+
|
124 |
+
def get_demo():
|
125 |
+
editings_table = pd.read_csv("editings_table.csv")
|
126 |
+
editings_table = editings_table.style.set_properties(**{'text-align': 'center'})
|
127 |
+
editings_table = editings_table.set_table_styles([dict(selector='th', props=[('text-align', 'center')])])
|
128 |
+
|
129 |
+
with gr.Blocks() as demo:
|
130 |
+
gr.Markdown("## StyleFeatureEditor")
|
131 |
+
gr.Markdown(
|
132 |
+
'<div style="display: flex; align-items: center; gap: 10px;">'
|
133 |
+
'<span>Official Gradio demo for StyleFeatureEditor:</span>'
|
134 |
+
'<a href="https://arxiv.org/abs/2406.10601"><img src="https://img.shields.io/badge/arXiv-2404.01094-b31b1b.svg" height=22.5></a>'
|
135 |
+
'<a href="https://github.com/AIRI-Institute/StyleFeatureEditor"><img src="https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white" height=22.5></a>'
|
136 |
+
'<a href="https://huggingface.co/AIRI-Institute/StyleFeatureEditor"><img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/model-on-hf-md.svg" height=22.5></a>'
|
137 |
+
'<a href="https://colab.research.google.com/#fileId=https://github.com/AIRI-Institute/StyleFeatureEditor/blob/main/notebook/StyleFeatureEditor_inference.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" height=22.5></a>'
|
138 |
+
'</div>'
|
139 |
+
)
|
140 |
+
with gr.Row():
|
141 |
+
with gr.Column():
|
142 |
+
with gr.Accordion("Input Image", open=True):
|
143 |
+
input_image = gr.Image(label="Input image you want to edit", type="pil", height=300)
|
144 |
+
align = gr.Checkbox(label="Align (crop and resize) the input image. For SFE to work well, it is necessary to align the input if it is not.", value=True)
|
145 |
+
with gr.Accordion("Predefined Editings", open=True):
|
146 |
+
with gr.Accordion("Description", open=False):
|
147 |
+
gr.Markdown('''A branch of predefined editings gained from InterfaceGAN, Stylespace, GANSpace and StyleClip mappers. Look at the table below to see which direction is responsible for which editings, and which edit power to use.
|
148 |
+
|
149 |
+
**Editing power** -- the greater the absolute value of this parameter, the more the selected edit will appear.
|
150 |
+
|
151 |
+
**Editing effect** -- the effect applied to the image when positive editing power is used. If negative power is used, the effect is reversed.
|
152 |
+
|
153 |
+
**Editing range** -- the approximate range of editing powers over which editing works well. We have found this empirically, so it may vary from image to image. Using powers outside the range may cause artefacts.
|
154 |
+
|
155 |
+
'''
|
156 |
+
)
|
157 |
+
|
158 |
+
gr.Dataframe(value=editings_table, datatype=["markdown","markdown","markdown","markdown"], interactive=False, wrap=True,
|
159 |
+
column_widths=["25px", "30px", "15px", "30px"], height=300)
|
160 |
+
with gr.Row():
|
161 |
+
predef_editing_direction = gr.Dropdown(PREDEFINED_EDITINGS_LIST, label="Editing direction", value="smile")
|
162 |
+
predef_editing_power = gr.Number(value=7, label="Editing power")
|
163 |
+
btn_predef = gr.Button("Edit image")
|
164 |
+
|
165 |
+
with gr.Accordion("Text Prompt (StyleClip) Editings", open=False):
|
166 |
+
with gr.Accordion("Description", open=False):
|
167 |
+
gr.Markdown('''You can alse use editings from text prompts via **StyleClip Global Mapper** (https://arxiv.org/abs/2103.17249). You just need to choose:
|
168 |
+
|
169 |
+
**Editing power** -- the greater the absolute value of this parameter, the more the selected edit will appear.
|
170 |
+
|
171 |
+
**Neutral prompt** -- some neutral description of the original image (e.g. "a face").
|
172 |
+
|
173 |
+
**Target prompt** -- text that contains the desired edit (e.g. "a smilling face").
|
174 |
+
|
175 |
+
**Disentanglement** -- positive number, the less this attribute -- the more related attributes will also be changed (e.g. for grey hair editing, wrinkle, skin colour and glasses may also be edited)
|
176 |
+
''')
|
177 |
+
|
178 |
+
neutral_prompt = gr.Textbox(value="face with hair", label="Neutreal prompt (e.g. 'a face')")
|
179 |
+
target_prompt = gr.Textbox(value="face with fire hair", label="Target prompt (e.g. 'a smilling face')")
|
180 |
+
styleclip_editing_power = gr.Slider(-50, 50, value=10, step=1, label="Editing power")
|
181 |
+
disentanglement = gr.Slider(0, 1, value=0.1, step=0.01, label="Disentanglement")
|
182 |
+
btn_clip = gr.Button("Edit image")
|
183 |
+
|
184 |
+
with gr.Accordion("Mask settings (optional)", open=False):
|
185 |
+
gr.Markdown('''If some artefacts appear during editing (or some details disappear), you can specify an image mask to select which regions of the image should not be edited. The mask must have a size of 1024 x 1024 and represent an inversion of the original image.
|
186 |
+
|
187 |
+
'''
|
188 |
+
)
|
189 |
+
mask = gr.Image(label="Upload mask for editing", type="pil", height=350)
|
190 |
+
with gr.Accordion("Mask generating", open=False):
|
191 |
+
gr.Markdown("Here you can generate mask that separates face (with hair) from the background.")
|
192 |
+
with gr.Row():
|
193 |
+
input_mask = gr.Image(label="Input image for mask generating", type="pil", height=240)
|
194 |
+
output_mask = gr.Image(label="Generated mask", height=240)
|
195 |
+
error_message_mask = gr.Textbox(label="⚠️ Error ⚠️", visible=False, elem_classes="error-message")
|
196 |
+
align_mask = gr.Checkbox(label="To align (crop and resize image) or not. Only uncheck this box if the original image has already been aligned.", value=True)
|
197 |
+
mask_trashhold = gr.Slider(0, 1, value=0.9, step=0.001, label="Mask trashold",
|
198 |
+
info="The more this parameter, the more is face part, and the less is background part.")
|
199 |
+
btn_mask = gr.Button("Generate mask")
|
200 |
+
|
201 |
+
with gr.Column():
|
202 |
+
with gr.Row():
|
203 |
+
output_inv = gr.Image(label="Inversion result", visible=True)
|
204 |
+
output_edit = gr.Image(label="Editing result", visible=True)
|
205 |
+
error_message = gr.Textbox(label="⚠️ Error ⚠️", visible=False, elem_classes="error-message")
|
206 |
+
gr.Examples(
|
207 |
+
label="Input Examples",
|
208 |
+
examples=[
|
209 |
+
["images/scarlet.jpg", "images/scarlet.jpg"],
|
210 |
+
["images/gosling.jpg", "images/gosling.jpg"],
|
211 |
+
["images/robert.png", "images/robert.png"],
|
212 |
+
["images/smith.jpg", "images/smith.jpg"],
|
213 |
+
["images/watson.jpeg", "images/watson.jpeg"],
|
214 |
+
],
|
215 |
+
inputs=[input_image, input_mask]
|
216 |
+
)
|
217 |
+
|
218 |
+
|
219 |
+
btn_predef.click(
|
220 |
+
fn=edit_image,
|
221 |
+
inputs=[input_image, predef_editing_direction, predef_editing_power, align, mask],
|
222 |
+
outputs=[output_edit, output_inv, error_message]
|
223 |
+
)
|
224 |
+
btn_clip.click(
|
225 |
+
fn=edit_image_clip,
|
226 |
+
inputs=[input_image, neutral_prompt, target_prompt, disentanglement, styleclip_editing_power, align, mask],
|
227 |
+
outputs=[output_edit, output_inv, error_message]
|
228 |
+
)
|
229 |
+
btn_mask.click(
|
230 |
+
fn=get_mask,
|
231 |
+
inputs=[input_mask, align_mask, mask_trashhold],
|
232 |
+
outputs=[output_mask, error_message_mask]
|
233 |
+
)
|
234 |
+
|
235 |
+
gr.Markdown('''To cite the paper by the authors
|
236 |
+
```
|
237 |
+
@InProceedings{Bobkov_2024_CVPR,
|
238 |
+
author = {Bobkov, Denis and Titov, Vadim and Alanov, Aibek and Vetrov, Dmitry},
|
239 |
+
title = {The Devil is in the Details: StyleFeatureEditor for Detail-Rich StyleGAN Inversion and High Quality Image Editing},
|
240 |
+
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
|
241 |
+
month = {June},
|
242 |
+
year = {2024},
|
243 |
+
pages = {9337-9346}
|
244 |
+
}
|
245 |
+
```
|
246 |
+
''')
|
247 |
+
return demo
|
248 |
+
|
249 |
+
|
250 |
+
if __name__ == '__main__':
|
251 |
+
demo = get_demo()
|
252 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
editings_table.csv
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Editing name,Editing effect,Editing range,Additional comments
|
2 |
+
glasses,add glasses,[-20; 30],may open mouth
|
3 |
+
smile,add smile,[-10; 10],
|
4 |
+
makeup,add make-up,[-10; 15],bad works with men
|
5 |
+
eye_openness,close eyes,[-30; 45],
|
6 |
+
trimmed_beard,remove beard,[-30; 30],bad works with women
|
7 |
+
lipstick,add lipstick,[-30; 30],bad works with men
|
8 |
+
face_roundness,make face rounder,[-20; 15],
|
9 |
+
nose_length,decreace nose length,[-30; 30],may open mouth
|
10 |
+
eyebrow_thickness,decreace eyebrow thickness,[-20; 20],
|
11 |
+
displeased,add sadness,[-10; 10],
|
12 |
+
age,increase age,[-10; 10],
|
13 |
+
rotation,turn face right,[-7 ; 7 ],
|
14 |
+
afro,afro hairstyle,[0; 0.14],
|
15 |
+
angry,make angrier,[0; 0.14],cause background artefacts
|
16 |
+
bobcut,bobcut hairstyle,[0; 0.18],cause background artefacts
|
17 |
+
bowlcut,bowlcut hairstyle,[0; 0.14],cause background artefacts
|
18 |
+
mohawk,mohawk hairstyle,[0; 0.10],cause background artefacts
|
19 |
+
curly_hair,add curls,[0; 0.12],
|
20 |
+
purple_hair,dye hair purple,[0; 0.12],
|
21 |
+
surprised,make more surprised,[0; 0.10],
|
22 |
+
beyonce,make similar to beyonce,[0; 0.12],
|
23 |
+
hilary_clinton,make similar to hilary clinton,[0; 0.10],
|
24 |
+
depp,make similar to johnny depp,[0; 0.12],
|
25 |
+
taylor_swift,make similar to taylor swift,[0; 0.10],
|
26 |
+
trump,make similar to donald trump,[0; 0.10],
|
27 |
+
zuckerberg,make similar to mark zuckerberg,[0; 0.10],
|
28 |
+
black hair,darken hair,[-7; 10],
|
29 |
+
blond hair,darken hair,[-10; 7],"yes, positive power darkens hair, negative lightens hair"
|
30 |
+
grey hair,make hair colored,[-7 ; 7],negative means make hair grey
|
31 |
+
wavy hair,add hair length,[-7 ; 7],
|
32 |
+
receding hairline,remove bald,[-10; 10],
|
33 |
+
sideburns,remove sideburns,[-7 ; 7],bad works with women
|
34 |
+
goatee,remove goatee,[-7 ; 7],bad works with women
|
35 |
+
earrings,add earrings,[0 ; 15],bad works with men
|
36 |
+
gender,add femininity,[-10; 7],better use global mapper
|
images/gosling.jpg
ADDED
images/robert.png
ADDED
images/scarlet.jpg
ADDED
images/smith.jpg
ADDED
images/watson.jpeg
ADDED
inference_pb2.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3 |
+
# source: inference.proto
|
4 |
+
# Protobuf Python Version: 5.26.1
|
5 |
+
"""Generated protocol buffer code."""
|
6 |
+
from google.protobuf import descriptor as _descriptor
|
7 |
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
8 |
+
from google.protobuf import symbol_database as _symbol_database
|
9 |
+
from google.protobuf.internal import builder as _builder
|
10 |
+
# @@protoc_insertion_point(imports)
|
11 |
+
|
12 |
+
_sym_db = _symbol_database.Default()
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0finference.proto\x12\tinference\"r\n\nSFERequest\x12\x12\n\norig_image\x18\x01 \x01(\x0c\x12\x11\n\tdirection\x18\x02 \x01(\t\x12\r\n\x05power\x18\x03 \x01(\x02\x12\x11\n\tuse_cache\x18\x04 \x01(\x08\x12\r\n\x05\x61lign\x18\x05 \x01(\x08\x12\x0c\n\x04mask\x18\x06 \x01(\x0c\"X\n\x0eSFERequestMask\x12\x12\n\norig_image\x18\x01 \x01(\x0c\x12\x10\n\x08trashold\x18\x02 \x01(\x02\x12\x11\n\tuse_cache\x18\x03 \x01(\x08\x12\r\n\x05\x61lign\x18\x04 \x01(\x08\"/\n\x0bSFEResponse\x12\r\n\x05image\x18\x01 \x01(\x0c\x12\x11\n\tinv_image\x18\x02 \x01(\x0c\"\x1f\n\x0fSFEResponseMask\x12\x0c\n\x04mask\x18\x01 \x01(\x0c\x32\x8b\x01\n\nSFEService\x12\x35\n\x04\x65\x64it\x12\x15.inference.SFERequest\x1a\x16.inference.SFEResponse\x12\x46\n\rgenerate_mask\x12\x19.inference.SFERequestMask\x1a\x1a.inference.SFEResponseMaskb\x06proto3')
|
18 |
+
|
19 |
+
_globals = globals()
|
20 |
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
21 |
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'inference_pb2', _globals)
|
22 |
+
if not _descriptor._USE_C_DESCRIPTORS:
|
23 |
+
DESCRIPTOR._loaded_options = None
|
24 |
+
_globals['_SFEREQUEST']._serialized_start=30
|
25 |
+
_globals['_SFEREQUEST']._serialized_end=144
|
26 |
+
_globals['_SFEREQUESTMASK']._serialized_start=146
|
27 |
+
_globals['_SFEREQUESTMASK']._serialized_end=234
|
28 |
+
_globals['_SFERESPONSE']._serialized_start=236
|
29 |
+
_globals['_SFERESPONSE']._serialized_end=283
|
30 |
+
_globals['_SFERESPONSEMASK']._serialized_start=285
|
31 |
+
_globals['_SFERESPONSEMASK']._serialized_end=316
|
32 |
+
_globals['_SFESERVICE']._serialized_start=319
|
33 |
+
_globals['_SFESERVICE']._serialized_end=458
|
34 |
+
# @@protoc_insertion_point(module_scope)
|
inference_pb2_grpc.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
2 |
+
"""Client and server classes corresponding to protobuf-defined services."""
|
3 |
+
import grpc
|
4 |
+
import warnings
|
5 |
+
|
6 |
+
import inference_pb2 as inference__pb2
|
7 |
+
|
8 |
+
GRPC_GENERATED_VERSION = '1.64.1'
|
9 |
+
GRPC_VERSION = grpc.__version__
|
10 |
+
EXPECTED_ERROR_RELEASE = '1.65.0'
|
11 |
+
SCHEDULED_RELEASE_DATE = 'June 25, 2024'
|
12 |
+
_version_not_supported = False
|
13 |
+
|
14 |
+
try:
|
15 |
+
from grpc._utilities import first_version_is_lower
|
16 |
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
17 |
+
except ImportError:
|
18 |
+
_version_not_supported = True
|
19 |
+
|
20 |
+
if _version_not_supported:
|
21 |
+
warnings.warn(
|
22 |
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
23 |
+
+ f' but the generated code in inference_pb2_grpc.py depends on'
|
24 |
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
25 |
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
26 |
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
27 |
+
+ f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
|
28 |
+
+ f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
|
29 |
+
RuntimeWarning
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
class SFEServiceStub(object):
|
34 |
+
"""Missing associated documentation comment in .proto file."""
|
35 |
+
|
36 |
+
def __init__(self, channel):
|
37 |
+
"""Constructor.
|
38 |
+
|
39 |
+
Args:
|
40 |
+
channel: A grpc.Channel.
|
41 |
+
"""
|
42 |
+
self.edit = channel.unary_unary(
|
43 |
+
'/inference.SFEService/edit',
|
44 |
+
request_serializer=inference__pb2.SFERequest.SerializeToString,
|
45 |
+
response_deserializer=inference__pb2.SFEResponse.FromString,
|
46 |
+
_registered_method=True)
|
47 |
+
self.generate_mask = channel.unary_unary(
|
48 |
+
'/inference.SFEService/generate_mask',
|
49 |
+
request_serializer=inference__pb2.SFERequestMask.SerializeToString,
|
50 |
+
response_deserializer=inference__pb2.SFEResponseMask.FromString,
|
51 |
+
_registered_method=True)
|
52 |
+
|
53 |
+
|
54 |
+
class SFEServiceServicer(object):
|
55 |
+
"""Missing associated documentation comment in .proto file."""
|
56 |
+
|
57 |
+
def edit(self, request, context):
|
58 |
+
"""Missing associated documentation comment in .proto file."""
|
59 |
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
60 |
+
context.set_details('Method not implemented!')
|
61 |
+
raise NotImplementedError('Method not implemented!')
|
62 |
+
|
63 |
+
def generate_mask(self, request, context):
|
64 |
+
"""Missing associated documentation comment in .proto file."""
|
65 |
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
66 |
+
context.set_details('Method not implemented!')
|
67 |
+
raise NotImplementedError('Method not implemented!')
|
68 |
+
|
69 |
+
|
70 |
+
def add_SFEServiceServicer_to_server(servicer, server):
|
71 |
+
rpc_method_handlers = {
|
72 |
+
'edit': grpc.unary_unary_rpc_method_handler(
|
73 |
+
servicer.edit,
|
74 |
+
request_deserializer=inference__pb2.SFERequest.FromString,
|
75 |
+
response_serializer=inference__pb2.SFEResponse.SerializeToString,
|
76 |
+
),
|
77 |
+
'generate_mask': grpc.unary_unary_rpc_method_handler(
|
78 |
+
servicer.generate_mask,
|
79 |
+
request_deserializer=inference__pb2.SFERequestMask.FromString,
|
80 |
+
response_serializer=inference__pb2.SFEResponseMask.SerializeToString,
|
81 |
+
),
|
82 |
+
}
|
83 |
+
generic_handler = grpc.method_handlers_generic_handler(
|
84 |
+
'inference.SFEService', rpc_method_handlers)
|
85 |
+
server.add_generic_rpc_handlers((generic_handler,))
|
86 |
+
server.add_registered_method_handlers('inference.SFEService', rpc_method_handlers)
|
87 |
+
|
88 |
+
|
89 |
+
# This class is part of an EXPERIMENTAL API.
|
90 |
+
class SFEService(object):
|
91 |
+
"""Missing associated documentation comment in .proto file."""
|
92 |
+
|
93 |
+
@staticmethod
|
94 |
+
def edit(request,
|
95 |
+
target,
|
96 |
+
options=(),
|
97 |
+
channel_credentials=None,
|
98 |
+
call_credentials=None,
|
99 |
+
insecure=False,
|
100 |
+
compression=None,
|
101 |
+
wait_for_ready=None,
|
102 |
+
timeout=None,
|
103 |
+
metadata=None):
|
104 |
+
return grpc.experimental.unary_unary(
|
105 |
+
request,
|
106 |
+
target,
|
107 |
+
'/inference.SFEService/edit',
|
108 |
+
inference__pb2.SFERequest.SerializeToString,
|
109 |
+
inference__pb2.SFEResponse.FromString,
|
110 |
+
options,
|
111 |
+
channel_credentials,
|
112 |
+
insecure,
|
113 |
+
call_credentials,
|
114 |
+
compression,
|
115 |
+
wait_for_ready,
|
116 |
+
timeout,
|
117 |
+
metadata,
|
118 |
+
_registered_method=True)
|
119 |
+
|
120 |
+
@staticmethod
|
121 |
+
def generate_mask(request,
|
122 |
+
target,
|
123 |
+
options=(),
|
124 |
+
channel_credentials=None,
|
125 |
+
call_credentials=None,
|
126 |
+
insecure=False,
|
127 |
+
compression=None,
|
128 |
+
wait_for_ready=None,
|
129 |
+
timeout=None,
|
130 |
+
metadata=None):
|
131 |
+
return grpc.experimental.unary_unary(
|
132 |
+
request,
|
133 |
+
target,
|
134 |
+
'/inference.SFEService/generate_mask',
|
135 |
+
inference__pb2.SFERequestMask.SerializeToString,
|
136 |
+
inference__pb2.SFEResponseMask.FromString,
|
137 |
+
options,
|
138 |
+
channel_credentials,
|
139 |
+
insecure,
|
140 |
+
call_credentials,
|
141 |
+
compression,
|
142 |
+
wait_for_ready,
|
143 |
+
timeout,
|
144 |
+
metadata,
|
145 |
+
_registered_method=True)
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pillow==10.3.0
|
2 |
+
pandas==2.2.2
|
3 |
+
gradio==4.37.1
|
4 |
+
grpcio==1.63.0
|
5 |
+
grpcio_tools==1.63.0
|
6 |
+
addict==2.4.0
|
7 |
+
gdown==3.12.2
|