Spaces:
Sleeping
Sleeping
darwinharianto
commited on
Commit
•
4fbe86d
1
Parent(s):
0f6b9c2
added japanese
Browse files
app.py
CHANGED
@@ -122,9 +122,39 @@ def process(width:int, height:int, scale:float, image: np.ndarray):
|
|
122 |
|
123 |
return [figure, text]
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
if __name__ == "__main__":
|
|
|
126 |
with gr.Blocks() as demo:
|
127 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
"""
|
129 |
# Image fitting
|
130 |
### Given Image input, fit as many as possible x number of input on canvas
|
@@ -133,7 +163,7 @@ if __name__ == "__main__":
|
|
133 |
|
134 |
with gr.Row():
|
135 |
with gr.Column():
|
136 |
-
image = gr.Image(image_mode="RGBA")
|
137 |
with gr.Row():
|
138 |
width = gr.Slider(value=1500, minimum=100, maximum=8000, label="Width")
|
139 |
height = gr.Slider(value=1500, minimum=100, maximum=8000, label="Height")
|
@@ -141,9 +171,10 @@ if __name__ == "__main__":
|
|
141 |
fit = gr.Button("Submit")
|
142 |
|
143 |
with gr.Column():
|
144 |
-
plot_output = gr.Plot()
|
145 |
-
text = gr.Text(label="
|
146 |
-
|
|
|
147 |
fit.click(fn=process, inputs=[width, height, scale, image], outputs=[plot_output, text])
|
148 |
|
149 |
|
|
|
122 |
|
123 |
return [figure, text]
|
124 |
|
125 |
+
def change_language(languageSelection):
|
126 |
+
|
127 |
+
return [
|
128 |
+
gr.Dropdown.update(value="English" if languageSelection == "English" else "日本語"),
|
129 |
+
gr.Slider.update(label="Width" if languageSelection == "English" else "横長"),
|
130 |
+
gr.Slider.update(label="Height" if languageSelection == "English" else "縦長"),
|
131 |
+
gr.Slider.update(label="Input Scale" if languageSelection == "English" else "入力拡大"),
|
132 |
+
gr.Markdown.update(
|
133 |
+
"""
|
134 |
+
# Image fitting
|
135 |
+
### Given Image input, fit as many as possible x number of input on canvas
|
136 |
+
"""
|
137 |
+
if languageSelection == "English" else
|
138 |
+
"""
|
139 |
+
# 画像フィッティング
|
140 |
+
### 画像入力すると、キャンバス上の入力の数 x できるだけ多く収まります
|
141 |
+
"""),
|
142 |
+
gr.Image.update(label="Image" if languageSelection == "English" else "画像入力", ),
|
143 |
+
gr.Text.update(label="Result" if languageSelection == "English" else "結果"),
|
144 |
+
gr.Button.update("Submit" if languageSelection == "English" else "送信"),
|
145 |
+
gr.Plot.update(label="Plot" if languageSelection == "English" else "プロット"),
|
146 |
+
]
|
147 |
+
|
148 |
if __name__ == "__main__":
|
149 |
+
options = ["English", "日本語"]
|
150 |
with gr.Blocks() as demo:
|
151 |
+
with gr.Row():
|
152 |
+
with gr.Column(scale=8):
|
153 |
+
pass
|
154 |
+
with gr.Column():
|
155 |
+
languageSelection = gr.Dropdown(options, value="English", show_label=False)
|
156 |
+
|
157 |
+
desc = gr.Markdown(
|
158 |
"""
|
159 |
# Image fitting
|
160 |
### Given Image input, fit as many as possible x number of input on canvas
|
|
|
163 |
|
164 |
with gr.Row():
|
165 |
with gr.Column():
|
166 |
+
image = gr.Image(image_mode="RGBA", label="Image")
|
167 |
with gr.Row():
|
168 |
width = gr.Slider(value=1500, minimum=100, maximum=8000, label="Width")
|
169 |
height = gr.Slider(value=1500, minimum=100, maximum=8000, label="Height")
|
|
|
171 |
fit = gr.Button("Submit")
|
172 |
|
173 |
with gr.Column():
|
174 |
+
plot_output = gr.Plot(label="Plot")
|
175 |
+
text = gr.Text(label="Result")
|
176 |
+
|
177 |
+
languageSelection.change(fn=change_language,inputs=[languageSelection] , outputs=[languageSelection, width, height, scale, desc, image, text, fit, plot_output])
|
178 |
fit.click(fn=process, inputs=[width, height, scale, image], outputs=[plot_output, text])
|
179 |
|
180 |
|