Spaces:
Running
Running
File size: 2,256 Bytes
3ecbc8c 12864d0 77d0b69 3ecbc8c 77d0b69 3ecbc8c 77d0b69 3ecbc8c 77d0b69 3ecbc8c 77d0b69 3ecbc8c 77d0b69 3ecbc8c 008b67a 3ecbc8c 2758e26 3ecbc8c f6d476a 3ecbc8c daafbac 3ecbc8c daafbac 3ecbc8c 7f9d0aa f6d476a 7f9d0aa 12864d0 7f9d0aa 12864d0 3ecbc8c 12864d0 3ecbc8c 12864d0 3ecbc8c 12864d0 3ecbc8c f6d476a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# from flask import Flask, request, jsonify
from handler import EndpointHandler
# app = Flask(__name__)
# handler = EndpointHandler()
# @app.route('/process_image', methods=['POST'])
# def process_image():
# data = request.json
# if data is None:
# return jsonify({'error': 'No JSON data received'}), 400
# try:
# result_image = handler(data)
# except Exception as e:
# return jsonify({'error': str(e)}), 500
# # Convert PIL image to base64 string
# buffered = BytesIO()
# result_image.save(buffered, format="JPEG")
# result_image_str = base64.b64encode(buffered.getvalue()).decode()
# return jsonify({'result_image': result_image_str})
# if __name__ == '__main__':
# app.run(debug=False,port=8001)
import easyocr as ocr #OCR
import torch
import streamlit as st #Web App
from PIL import Image #Image Processing
import numpy as np #Image Processing
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
#title
st.title("Make Your Videos More Beautiful with Devticks services")
prompt = st.text_input("Enter your prompt here")
#image uploader
image = st.file_uploader(label = "Upload your image here",type=['png','jpg','jpeg'])
@st.cache
def load_model():
reader = ocr.Reader(['en'],model_storage_directory='.')
return reader
reader = load_model() #load model
if image is not None:
input_image = Image.open(image) #read image
st.image(input_image) #display image
with st.spinner("π€ AI is at Work! "):
model_id = "timbrooks/instruct-pix2pix"
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
pipe.to("cuda")
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
images = pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
images[0].show()
# result_text = [] #empty list for results
# for text in result:
# result_text.append(text[1])
# st.write(result_text)
#st.success("Here you go!")
st.balloons()
else:
st.write("Upload an Image")
st.caption("π€")
|