Spaces:
Runtime error
Runtime error
twtiter link
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import base64
|
|
| 5 |
from scripts.process_utils import initialize, process_image_as_base64, image_to_base64
|
| 6 |
from scripts.anime import init_model
|
| 7 |
from scripts.generate_prompt import load_wd14_tagger_model
|
|
|
|
| 8 |
|
| 9 |
# εζε
|
| 10 |
initialize(_use_local=False, use_gpu=True, use_dotenv=True)
|
|
@@ -38,6 +39,15 @@ def mix_images(sotai_image_data, sketch_image_data, opacity1, opacity2):
|
|
| 38 |
|
| 39 |
return mixed_image
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
with gr.Blocks() as demo:
|
| 42 |
# title
|
| 43 |
gr.HTML("<h1>Image2Body demo</h1>")
|
|
@@ -68,6 +78,12 @@ with gr.Blocks() as demo:
|
|
| 68 |
mixed_image = gr.Image(label="Output Image", elem_id="output_image")
|
| 69 |
opacity_slider1 = gr.Slider(0, 1, value=0.5, step=0.05, label="Opacity (Sotai)")
|
| 70 |
opacity_slider2 = gr.Slider(0, 1, value=0.5, step=0.05, label="Opacity (Sketch)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
original_submit.click(
|
| 73 |
process_image,
|
|
|
|
| 5 |
from scripts.process_utils import initialize, process_image_as_base64, image_to_base64
|
| 6 |
from scripts.anime import init_model
|
| 7 |
from scripts.generate_prompt import load_wd14_tagger_model
|
| 8 |
+
import webbrowser
|
| 9 |
|
| 10 |
# εζε
|
| 11 |
initialize(_use_local=False, use_gpu=True, use_dotenv=True)
|
|
|
|
| 39 |
|
| 40 |
return mixed_image
|
| 41 |
|
| 42 |
+
# X(Twitter)γ«ζη¨Ώγγγͺγ³γ―γηζ
|
| 43 |
+
def generate_twitter_link(image):
|
| 44 |
+
image_base64 = image_to_base64(image)
|
| 45 |
+
return f"https://twitter.com/intent/tweet?text=Image2Body&url={image_base64} #Image2Body"
|
| 46 |
+
|
| 47 |
+
def post_to_twitter(image):
|
| 48 |
+
link = generate_twitter_link(image)
|
| 49 |
+
webbrowser.open_new_tab(link)
|
| 50 |
+
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
# title
|
| 53 |
gr.HTML("<h1>Image2Body demo</h1>")
|
|
|
|
| 78 |
mixed_image = gr.Image(label="Output Image", elem_id="output_image")
|
| 79 |
opacity_slider1 = gr.Slider(0, 1, value=0.5, step=0.05, label="Opacity (Sotai)")
|
| 80 |
opacity_slider2 = gr.Slider(0, 1, value=0.5, step=0.05, label="Opacity (Sketch)")
|
| 81 |
+
post_button = gr.Button("Post to X(Twitter)", variant="secondary")
|
| 82 |
+
post_button.click(
|
| 83 |
+
post_to_twitter,
|
| 84 |
+
inputs=[mixed_image],
|
| 85 |
+
outputs=None
|
| 86 |
+
)
|
| 87 |
|
| 88 |
original_submit.click(
|
| 89 |
process_image,
|