f4a9d22
user_wwq 3 years ago
3 changed file(s) with 51 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
2222 img = np.array(Image.open(in_PATH).convert('RGB'))[np.newaxis] / 255.0
2323 img_p = util.preprocess_images_outpainting(img)
2424 return img_p
25
26 def image_to_path(img):
27 resize_img = img
28 path = uuid.uuid4().hex + '.png'
29 resize_img.save(path)
30 return path
2531
2632 @run_time
2733 def inference(model_PATH, img_p):
4955 base64_str = conf['Photo']
5056 image = load_demo_image(base64_str, image_size, device)
5157 res = inference(model_PATH, image)
52 # add your code
58 image_str = image_to_path(res)
5359 return {'Output': res}
5460
22 {
33 "cell_type": "code",
44 "execution_count": 3,
5 "id": "04c7f16a",
5 "id": "a0f197c0",
66 "metadata": {},
77 "outputs": [
88 {
3939 {
4040 "cell_type": "code",
4141 "execution_count": 4,
42 "id": "0dd13c75",
42 "id": "35638e2a",
4343 "metadata": {},
4444 "outputs": [],
4545 "source": [
4949 {
5050 "cell_type": "code",
5151 "execution_count": 9,
52 "id": "649a883e",
52 "id": "bfa0229a",
5353 "metadata": {},
5454 "outputs": [],
5555 "source": [
6666 {
6767 "cell_type": "code",
6868 "execution_count": 8,
69 "id": "fba4c6ff",
69 "id": "57494ceb",
7070 "metadata": {},
7171 "outputs": [],
7272 "source": [
7878 },
7979 {
8080 "cell_type": "code",
81 "execution_count": 11,
82 "id": "d1ab22e6",
83 "metadata": {},
84 "outputs": [],
85 "source": [
86 "def image_to_path(img):\n",
87 " resize_img = img\n",
88 " path = uuid.uuid4().hex + '.png'\n",
89 " resize_img.save(path)\n",
90 " return path"
91 ]
92 },
93 {
94 "cell_type": "code",
8195 "execution_count": 6,
82 "id": "ff900f2b",
96 "id": "4a7370fa",
8397 "metadata": {},
8498 "outputs": [],
8599 "source": [
100114 },
101115 {
102116 "cell_type": "code",
103 "execution_count": 10,
104 "id": "9d164058",
117 "execution_count": 12,
118 "id": "b03bba02",
105119 "metadata": {},
106120 "outputs": [],
107121 "source": [
117131 " base64_str = conf['Photo']\n",
118132 " image = load_demo_image(base64_str, image_size, device)\n",
119133 " res = inference(model_PATH, image)\n",
120 " # add your code\n",
134 " image_str = image_to_path(res)\n",
121135 " return {'Output': res}\n",
122136 " "
123137 ]
22 {
33 "cell_type": "code",
44 "execution_count": 3,
5 "id": "755152e5",
5 "id": "29291686",
66 "metadata": {},
77 "outputs": [
88 {
3939 {
4040 "cell_type": "code",
4141 "execution_count": 4,
42 "id": "c45b2ba8",
42 "id": "67b9aae4",
4343 "metadata": {},
4444 "outputs": [],
4545 "source": [
4949 {
5050 "cell_type": "code",
5151 "execution_count": 9,
52 "id": "7eb0351a",
52 "id": "058a509a",
5353 "metadata": {},
5454 "outputs": [],
5555 "source": [
6666 {
6767 "cell_type": "code",
6868 "execution_count": 8,
69 "id": "196069cc",
69 "id": "7dd82ead",
7070 "metadata": {},
7171 "outputs": [],
7272 "source": [
7878 },
7979 {
8080 "cell_type": "code",
81 "execution_count": 11,
82 "id": "379d2efd",
83 "metadata": {},
84 "outputs": [],
85 "source": [
86 "def image_to_path(img):\n",
87 " resize_img = img\n",
88 " path = uuid.uuid4().hex + '.png'\n",
89 " resize_img.save(path)\n",
90 " return path"
91 ]
92 },
93 {
94 "cell_type": "code",
8195 "execution_count": 6,
82 "id": "e0a075d4",
96 "id": "70d5031c",
8397 "metadata": {},
8498 "outputs": [],
8599 "source": [
100114 },
101115 {
102116 "cell_type": "code",
103 "execution_count": 10,
104 "id": "c7dfafbb",
117 "execution_count": 12,
118 "id": "d7439afa",
105119 "metadata": {},
106120 "outputs": [],
107121 "source": [
117131 " base64_str = conf['Photo']\n",
118132 " image = load_demo_image(base64_str, image_size, device)\n",
119133 " res = inference(model_PATH, image)\n",
120 " # add your code\n",
134 " image_str = image_to_path(res)\n",
121135 " return {'Output': res}\n",
122136 " "
123137 ]