saraayum commited on
Commit
5b9dafc
·
verified ·
1 Parent(s): 79289c0

Upload 4 files

Browse files
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from inference import predict
3
+
4
+ interface = gr.Interface(
5
+ fn=predict,
6
+ inputs=gr.Image(type="filepath", label="Upload SAR Image"),
7
+ outputs="image",
8
+ title="SAR Image Colorization"
9
+ )
10
+
11
+ interface.launch()
inference.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tensorflow.keras.models import load_model
2
+ import numpy as np
3
+ from PIL import Image
4
+
5
+ # Load model
6
+ generator = load_model('generator_checkpoint.h5')
7
+
8
+ # Example inference
9
+ def predict(input_image_path, output_image_path):
10
+ img = Image.open(input_image_path).resize((256, 256))
11
+ img = np.array(img) / 255.0
12
+ img = np.expand_dims(img, axis=0)
13
+
14
+ output = generator.predict(img)
15
+ output = (output[0] * 255).astype('uint8')
16
+
17
+ Image.fromarray(output).save(output_image_path)
18
+
19
+ # Example usage
20
+ predict('sample_sar.png', 'predicted_colorized.png')
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ tensorflow==2.12.0
2
+ Pillow
3
+ gradio
4
+ numpy
sar_colorization_generator_final.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e015cd5be2afb027c24e99ba01b4099f9595cd898369b20471ff2538d197afb9
3
+ size 5328448