File size: 1,452 Bytes
273e64a
3cdf272
9c27333
3cdf272
56d08ee
3cdf272
 
 
 
 
 
56d08ee
3cdf272
 
 
 
 
 
 
 
 
9c27333
091614b
3cdf272
 
 
 
091614b
3cdf272
 
 
091614b
 
3cdf272
 
 
091614b
3cdf272
 
 
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
import os
import subprocess
import gradio as gr
from deoldify.visualize import get_image_colorizer, get_video_colorizer

# Vérifie si le dépôt DeOldify existe, sinon le clone
if not os.path.exists("DeOldify"):
    subprocess.run(["git", "clone", "https://github.com/jantic/DeOldify.git"])
    
# Change le répertoire de travail
os.chdir("DeOldify")

# Crée un fichier requirements.txt
with open("requirements.txt", "w") as f:
    f.write("\ndeoldify\ngradio\ntorch\nopencv-python\n")

# Installe les dépendances
subprocess.run(["pip", "install", "-r", "requirements.txt"])

# Initialiser les colorisateurs
image_colorizer = get_image_colorizer()
video_colorizer = get_video_colorizer()

def colorize_image(input_image):
    # Processer l'image d'entrée et retourner la version colorisée
    colorized_image = image_colorizer.get_transformed_image(input_image)
    return colorized_image

def colorize_video(input_video):
    # Processer la vidéo d'entrée et retourner la version colorisée
    colorized_video = video_colorizer.get_transformed_video(input_video)
    return colorized_video

# Créer l'interface Gradio
image_interface = gr.Interface(fn=colorize_image, inputs="image", outputs="image", title="Colorisation d'Image")
video_interface = gr.Interface(fn=colorize_video, inputs="video", outputs="video", title="Colorisation de Vidéo")

# Lancer les interfaces
image_interface.launch(share=True)
video_interface.launch(share=True)