Created
April 7, 2023 17:39
-
-
Save AIAnytime/f0026b78be68a7f2da58ac84e793a5c2 to your computer and use it in GitHub Desktop.
reverse_sd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""Reverse SD.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at | |
https://colab.research.google.com/drive/1ci11cstH7uM9SPb6q2hb7f-IiZHYvcDq | |
""" | |
!pip install clip-interrogator==0.6.0 | |
from PIL import Image | |
from clip_interrogator import Config, Interrogator | |
image = Image.open("monalisa.png").convert('RGB') | |
image | |
ci = Interrogator(Config(clip_model_name="ViT-L-14/openai")) | |
print(ci.interrogate(image)) | |
import locale | |
locale.getpreferredencoding = lambda: "UTF-8" | |
!pip install gradio | |
import gradio as gr | |
import re | |
def reverse_sd(image): | |
image = Image.fromarray(image) | |
ci = Interrogator(Config(clip_model_name="ViT-L-14/openai")) | |
result = ci.interrogate(image) | |
return result | |
demo = gr.Interface(fn=reverse_sd, inputs="image", outputs="text") | |
demo.launch(share=True, debug=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment