Commit
·
5883a4e
1
Parent(s):
4230bd7
Update parquet files (step 25 of 121)
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- spaces/0x7194633/nllb-1.3B-demo/README.md +0 -12
- spaces/0xHacked/zkProver/app.py +0 -77
- spaces/1acneusushi/gradio-2dmoleculeeditor/data/Ao No Kanata Four Rhythm Crack.md +0 -32
- spaces/1gistliPinn/ChatGPT4/Examples/Crack _BEST_ Vba Project Password Recovery 13.md +0 -50
- spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Car Parking Multiplayer v4.8.8.3 Mod Apk - Unlock All Cars and Maps for Free.md +0 -105
- spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/CarX Highway Racing APK Hackeado The Best Racing Game on Android.md +0 -82
- spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/CarX Street The Best Street Racing Game for Android Users.md +0 -130
- spaces/1phancelerku/anime-remove-background/CSR Racing 2 MOD APK The Ultimate Fast and Furious Racing Game for Android.md +0 -97
- spaces/1phancelerku/anime-remove-background/Download PowerShell 2.0 and WinRM 2.0 for Windows XP and Windows Server 2003.md +0 -176
- spaces/1phancelerku/anime-remove-background/Download Urdu Subtitles for Game of Thrones Season 2 Episode 5 The Ghost of Harrenhal.md +0 -201
- spaces/1phancelerku/anime-remove-background/Drag Racing Streets Mod Apk A Physics-Based Racing Game with Unlimited Money and Customization.md +0 -96
- spaces/1phancelerku/anime-remove-background/Enjoy Action RPG and Free Shopping with Pixel Blade M VIP Mod APK.md +0 -117
- spaces/4Taps/SadTalker/src/face3d/models/arcface_torch/configs/ms1mv3_r34.py +0 -26
- spaces/A00001/bingothoo/src/components/ui/select.tsx +0 -123
- spaces/A666sxr/Genshin_TTS/transforms.py +0 -193
- spaces/AIWaves/Software_Company/src/agents/State.py +0 -142
- spaces/Abhilashvj/planogram-compliance/segment/train.py +0 -1104
- spaces/AchyuthGamer/OpenGPT-Chat-UI/src/lib/server/auth.ts +0 -118
- spaces/AchyuthGamer/OpenGPT/g4f/Provider/deprecated/Wuguokai.py +0 -63
- spaces/Aer0xander/sd-to-diffusers/hf_utils.py +0 -50
- spaces/Ameaou/academic-chatgpt3.1/crazy_functions/test_project/cpp/longcode/prod_cons.h +0 -433
- spaces/Amrrs/DragGan-Inversion/stylegan_human/torch_utils/ops/filtered_lrelu.cpp +0 -300
- spaces/Androidonnxfork/CivitAi-to-Diffusers/diffusers/src/diffusers/schedulers/scheduling_sde_ve.py +0 -288
- spaces/Andy1621/uniformer_image_segmentation/configs/deeplabv3/deeplabv3_r50b-d8_512x1024_80k_cityscapes.py +0 -2
- spaces/Andy1621/uniformer_image_segmentation/configs/encnet/encnet_r50s-d8_512x512_80k_ade20k.py +0 -8
- spaces/Andy1621/uniformer_image_segmentation/configs/gcnet/gcnet_r50-d8_512x512_160k_ade20k.py +0 -6
- spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/parallel/scatter_gather.py +0 -59
- spaces/Anonymous-sub/Rerender/ControlNet/cldm/hack.py +0 -111
- spaces/Apex-X/GODROOP/predictor.py +0 -22
- spaces/Artples/llama-2-7b-chat/app.py +0 -467
- spaces/AsakuraMizu/moe-tts/text/english.py +0 -188
- spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/chardet/big5freq.py +0 -386
- spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated.h +0 -115
- spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/data/test_rotation_transform.py +0 -71
- spaces/Bambicita/rvc-models/infer_pack/modules.py +0 -522
- spaces/Benson/text-generation/Examples/Descargar Ftbol Real 2010 Para Java.md +0 -56
- spaces/Benson/text-generation/Examples/Descargar Gacha Vida Vieja Versin Apk.md +0 -72
- spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_vendor/urllib3/connection.py +0 -572
- spaces/Big-Web/MMSD/env/Lib/site-packages/setuptools/_distutils/_msvccompiler.py +0 -572
- spaces/Billyosoro/ESRGAN/realesrgan/archs/discriminator_arch.py +0 -67
- spaces/BramVanroy/mai-simplification-nl-2023-demo/utils.py +0 -62
- spaces/CVPR/LIVE/pybind11/tests/test_embed/catch.cpp +0 -22
- spaces/CVPR/LIVE/thrust/thrust/merge.h +0 -680
- spaces/CVPR/WALT/docker/Dockerfile +0 -52
- spaces/CVPR/WALT/mmdet/models/dense_heads/anchor_free_head.py +0 -340
- spaces/CVPR/lama-example/saicinpainting/evaluation/masks/mask.py +0 -429
- spaces/CVPR/transfiner/configs/Misc/torchvision_imagenet_R_50.py +0 -150
- spaces/ChrisPreston/diff-svc_minato_aqua/modules/hubert/hubert_model.py +0 -243
- spaces/Cyril666/my_abi/modules/model.py +0 -50
- spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/ttLib/tables/_c_v_a_r.py +0 -86
spaces/0x7194633/nllb-1.3B-demo/README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Nllb Translation Demo
|
3 |
-
emoji: 👀
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: green
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.0.26
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/0xHacked/zkProver/app.py
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import tempfile
|
3 |
-
import uuid
|
4 |
-
import subprocess
|
5 |
-
import gradio as gr
|
6 |
-
|
7 |
-
|
8 |
-
BIN = os.path.join(os.path.dirname(__file__), "bin", "zkProver_linux_gpu")
|
9 |
-
|
10 |
-
|
11 |
-
def run_zk_prover(network, block_number, contract, file):
|
12 |
-
if not contract:
|
13 |
-
raise gr.Error("contract is required")
|
14 |
-
if not file:
|
15 |
-
raise gr.Error('file is required')
|
16 |
-
args = [
|
17 |
-
BIN,
|
18 |
-
"evm", "-r", "https://rpc.flashbots.net/"
|
19 |
-
]
|
20 |
-
if block_number:
|
21 |
-
args.extend(["-b", str(block_number)])
|
22 |
-
proof_path = "/tmp/" + str(uuid.uuid4()) + ".bin"
|
23 |
-
args.extend(["-o", proof_path])
|
24 |
-
|
25 |
-
args.append(file.name + ":" + contract)
|
26 |
-
|
27 |
-
proc = subprocess.Popen(args,)
|
28 |
-
proc.wait()
|
29 |
-
|
30 |
-
if proc.returncode != 0:
|
31 |
-
raise gr.Error("generate proof failed")
|
32 |
-
return proof_path
|
33 |
-
|
34 |
-
|
35 |
-
with gr.Blocks() as demo:
|
36 |
-
gr.Markdown(
|
37 |
-
"""
|
38 |
-
# 0xHacked
|
39 |
-
This is the demo for [0xHacked](https://0xHacked.com), a trustless bug bounty platform. You can generate the proof of exploit here. However, due to the constraints of ZKP, the generation might be low on Huggingface.
|
40 |
-
<br/>
|
41 |
-
We recommend [compiling it from the source](https://github.com/0xHackedLabs/zkProver). The generation can be very quick on GPU. For more details, please refer to [0xHacked Documentation](https://docs.0xHacked.com).
|
42 |
-
<br/>
|
43 |
-
The sample PoC provided below takes ~800s to generate the proof. You can click "SushiRouterExploit.sol" below and hit "Run" to try it!
|
44 |
-
"""
|
45 |
-
)
|
46 |
-
with gr.Column():
|
47 |
-
with gr.Row():
|
48 |
-
with gr.Column():
|
49 |
-
network_input = gr.Dropdown(["Ethereum"], value="Ethereum", label='Network')
|
50 |
-
block_number_input = gr.Number(precision=0, label='Block Number')
|
51 |
-
contract_input = gr.Textbox(label='Poc Contract')
|
52 |
-
file_input = gr.File(file_types=[".sol"], label='Solidity File')
|
53 |
-
submit_btn = gr.Button(label="Submit")
|
54 |
-
with gr.Column():
|
55 |
-
fileout = gr.File(label='Proof File')
|
56 |
-
|
57 |
-
gr.Examples(
|
58 |
-
examples=[[
|
59 |
-
"Ethereum",
|
60 |
-
17007841,
|
61 |
-
"SushiExpProxy",
|
62 |
-
"./examples/SushiRouterExploit.sol"],
|
63 |
-
],
|
64 |
-
fn=run_zk_prover,
|
65 |
-
inputs=[network_input, block_number_input, contract_input, file_input],
|
66 |
-
outputs=fileout
|
67 |
-
)
|
68 |
-
|
69 |
-
submit_btn.click(
|
70 |
-
fn=run_zk_prover,
|
71 |
-
inputs=[network_input, block_number_input, contract_input, file_input],
|
72 |
-
outputs=fileout
|
73 |
-
)
|
74 |
-
|
75 |
-
if __name__ == "__main__":
|
76 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1acneusushi/gradio-2dmoleculeeditor/data/Ao No Kanata Four Rhythm Crack.md
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>Ao no Kanata no Four Rhythm: A Visual Novel That Soars High</h1>
|
3 |
-
<p>Ao no Kanata no Four Rhythm (also known as Aokana: Four Rhythm Across the Blue) is a visual novel developed by sprite and released in 2014. It is set in a world where flying is as simple as riding a bicycle, thanks to the invention of anti-gravitational shoes known as Grav-Shoes. The game follows the protagonist, Masaya Hinata, a former competitor in a sport called Flying Circus, who regains his passion for flying when he meets the transfer student Asuka Kurashina. Together with their friends, they join the Kunahama High School Flying Circus club and aim for the top of the national tournament.</p>
|
4 |
-
<h2>ao no kanata four rhythm crack</h2><br /><p><b><b>DOWNLOAD</b> ☆☆☆ <a href="https://byltly.com/2uKxag">https://byltly.com/2uKxag</a></b></p><br /><br />
|
5 |
-
<p>The game features four main heroines, each with their own route and story. They are:</p>
|
6 |
-
<ul>
|
7 |
-
<li>Asuka Kurashina, a cheerful and energetic girl who loves flying and wants to learn everything about Flying Circus.</li>
|
8 |
-
<li>Misaki Tobisawa, a skilled and confident flyer who is Masaya's childhood friend and rival.</li>
|
9 |
-
<li>Mashiro Arisaka, a timid and clumsy girl who is Misaki's best friend and worries about her a lot.</li>
|
10 |
-
<li>Rika Ichinose, a genius inventor who creates new gadgets and strategies for Flying Circus.</li>
|
11 |
-
</ul>
|
12 |
-
<p>The game has been praised for its beautiful graphics, engaging gameplay, and emotional story. It has also been adapted into an anime series in 2016 and a manga series in 2015. The game has been released in English by NekoNyan Ltd. and HIKARI FIELD in 2019, with an 18+ DLC available for free on NekoNyanSoft shop. However, the game has mosaics censorship, which may disappoint some fans of the genre.</p>
|
13 |
-
<p>If you are looking for a visual novel that combines romance, comedy, drama, and sports, you may want to give Ao no Kanata no Four Rhythm a try. You can download the game from Steam or NekoNyanSoft shop, and enjoy the thrilling experience of flying with your favorite heroine.</p>
|
14 |
-
<p></p>
|
15 |
-
|
16 |
-
<p>One of the main attractions of Ao no Kanata no Four Rhythm is its gameplay, which simulates the Flying Circus matches in a 3D environment. The player can choose to control Masaya or one of the heroines, and compete against various opponents in different modes, such as time attack, point match, or survival. The player can also customize their Grav-Shoes and outfits, and unlock new skills and abilities as they progress through the game.</p>
|
17 |
-
<p>The gameplay is fast-paced and exhilarating, requiring the player to master the basics of flying, such as acceleration, turning, braking, and drifting. The player also has to use their tactics and reflexes to dodge attacks, counterattack, and perform special moves. The game offers multiple difficulty levels and adjustable settings, making it accessible for both beginners and veterans. The game also supports online multiplayer mode, where the player can challenge other players from around the world.</p>
|
18 |
-
<p>The game has received overwhelmingly positive reviews from both critics and users on Steam[^1^], who praised its gameplay, graphics, music, voice acting, and story. Some of the common compliments include:</p>
|
19 |
-
<blockquote>
|
20 |
-
<p>"One of the best visual novels I've ever played. The story is engaging, the characters are lovable, the art is gorgeous, and the gameplay is addictive."</p>
|
21 |
-
<p>"A masterpiece of a visual novel. The gameplay is fun and challenging, the story is emotional and captivating, and the music is beautiful and fitting."</p>
|
22 |
-
<p>"A visual novel that transcends its genre. The gameplay is not just a gimmick, but an integral part of the story and character development. The story is not just a romance, but a journey of growth and friendship."</p>
|
23 |
-
</blockquote>
|
24 |
-
<p>However, the game is not without its flaws. Some of the common criticisms include:</p>
|
25 |
-
<blockquote>
|
26 |
-
<p>"The game has mosaics censorship, which ruins the immersion and quality of the 18+ scenes."</p>
|
27 |
-
<p>"The game has some bugs and glitches, such as crashes, freezes, or missing text."</p>
|
28 |
-
<p>"The game has some translation errors and typos, such as grammar mistakes, inconsistent names, or wrong choices."</p>
|
29 |
-
</blockquote>
|
30 |
-
<p>Despite these issues, most reviewers agree that Ao no Kanata no Four Rhythm is a visual novel worth playing for its unique gameplay and compelling story. If you are a fan of visual novels or flying games, you should not miss this gem.</p> 81aa517590<br />
|
31 |
-
<br />
|
32 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1gistliPinn/ChatGPT4/Examples/Crack _BEST_ Vba Project Password Recovery 13.md
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>How to Crack VBA Project Password Recovery 13 in Excel</h1>
|
3 |
-
<p>If you have ever worked with VBA macros in Excel, you might have encountered a situation where you need to access or modify the code of a locked VBA project. This can happen when you inherit a workbook from someone else, or when you forget your own password. In this article, we will show you how to crack VBA project password recovery 13 in Excel using different methods.</p>
|
4 |
-
<h2>What is VBA Project Password Recovery 13?</h2>
|
5 |
-
<p>VBA project password recovery 13 is a term that refers to the process of unlocking a VBA project that is protected by a password in Excel. A VBA project is a collection of modules, forms, and classes that contain the code for your macros. You can protect your VBA project from unauthorized access or modification by setting a password in the VBA editor.</p>
|
6 |
-
<h2>crack vba project password recovery 13</h2><br /><p><b><b>Download File</b> →→→ <a href="https://imgfil.com/2uy1zd">https://imgfil.com/2uy1zd</a></b></p><br /><br />
|
7 |
-
<p>However, sometimes you might need to crack the password for various reasons, such as:</p>
|
8 |
-
<ul>
|
9 |
-
<li>You forgot your own password and cannot edit your macros.</li>
|
10 |
-
<li>You inherited a workbook from someone else and want to see how the macros work.</li>
|
11 |
-
<li>You want to learn from or improve the code of an existing VBA project.</li>
|
12 |
-
<li>You want to remove the password protection for easier maintenance or sharing.</li>
|
13 |
-
</ul>
|
14 |
-
<p>There are different ways to crack VBA project password recovery 13 in Excel, depending on the file format and the version of Excel you are using. We will cover some of the most common and effective methods in the following sections.</p>
|
15 |
-
<h2>How to Crack VBA Project Password Recovery 13 for Older .XLS Files</h2>
|
16 |
-
<p>If you are working with an older .XLS file (Excel 97-2003 format), you can use a simple hex editing technique to crack the password. Hex editing is a method of modifying the binary data of a file using a hexadecimal editor. You can use any hex editor software for this purpose, such as HxD or Notepad++.</p>
|
17 |
-
<p>Here are the steps to crack VBA project password recovery 13 for older .XLS files:</p>
|
18 |
-
<ol>
|
19 |
-
<li>Open the .XLS file in your hex editor.</li>
|
20 |
-
<li>Search for the text "DPB=" (without quotes) in the file. You should find it just above "[Host Extender Info]".</li>
|
21 |
-
<li>Change "DPB=" to "DPx=" (without quotes) and save the file.</li>
|
22 |
-
<li>Open the file in Excel and click Yes if you see a warning message about repairing the file.</li>
|
23 |
-
<li>Open the VBA editor (Alt+F11) and click OK if you see a warning message about opening the project.</li>
|
24 |
-
<li>Right-click the VBA project name, select Properties, go to the Protection tab and delete the existing passwords as well as uncheck the Lock project for viewing checkbox.</li>
|
25 |
-
<li>Re-check the Lock project for viewing checkbox and add your own memorable password. Click OK and save the file.</li>
|
26 |
-
</ol>
|
27 |
-
<p>Congratulations! You have successfully cracked VBA project password recovery 13 for older .XLS files. You can now access and modify the code of your macros as you wish.</p>
|
28 |
-
<h2>How to Crack VBA Project Password Recovery 13 for Newer .XLSM Files</h2>
|
29 |
-
<p>If you are working with a newer .XLSM file (Excel 2007 or later format), you can use a different technique that involves changing the file extension and extracting a binary file. A binary file is a file that contains data in a binary format, which can be read by computers but not by humans. You can use any archiver software for this purpose, such as WinRAR or 7-Zip.</p>
|
30 |
-
<p>Here are the steps to crack VBA project password recovery 13 for newer .XLSM files:</p>
|
31 |
-
<p></p>
|
32 |
-
<ol>
|
33 |
-
<li>Change the file extension of your .XLSM file to .ZIP. For example, if your file name is "MyWorkbook.xlsm", change it to "MyWorkbook.zip".</li>
|
34 |
-
<li>Open the .ZIP file in your archiver software and navigate to the "xl" folder inside it.</li>
|
35 |
-
<li>Extract the "vbaProject.bin" file from the "xl" folder to your desired location.</li>
|
36 |
-
<li>Perform steps #1-3 from the previous section (for older .XLS files) with "vbaProject.bin" instead of your original .XLSM file.</li>
|
37 |
-
<li>Replace the old "vbaProject.bin" file in the .ZIP file with the new hex edited version.</li>
|
38 |
-
<li>Change the file extension of your .ZIP file back to .XLSM. For example, if your file name is "MyWorkbook.zip", change it back to "MyWorkbook.xlsm".</li>
|
39 |
-
<li>Perform steps #4-7 from the previous section (for older .XLS files) with your original .XLSM file instead of "vbaProject.bin".</li>
|
40 |
-
</ol>
|
41 |
-
<p>Congratulations! You have successfully cracked VBA project password recovery 13 for newer .XLSM files. You can now access and modify the code of your macros as you wish.</p>
|
42 |
-
|
43 |
-
<h2>Conclusion</h2>
|
44 |
-
|
45 |
-
<p>In this article, we have shown you how to crack VBA project password recovery 13 in Excel using different methods. We hope this article was helpful and informative for you. However, we also advise you to use these methods responsibly and ethically, and not to violate any intellectual property rights or privacy policies of others. Remember that cracking passwords is not always legal or ethical, so use these methods at your own risk and discretion.</p>
|
46 |
-
<h2>Conclusion</h2>
|
47 |
-
|
48 |
-
<p>In this article, we have shown you how to crack VBA project password recovery 13 in Excel using different methods. We hope this article was helpful and informative for you. However, we also advise you to use these methods responsibly and ethically, and not to violate any intellectual property rights or privacy policies of others. Remember that cracking passwords is not always legal or ethical, so use these methods at your own risk and discretion.</p> 3cee63e6c2<br />
|
49 |
-
<br />
|
50 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Car Parking Multiplayer v4.8.8.3 Mod Apk - Unlock All Cars and Maps for Free.md
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>Car Parking Mod APK 4.8.8.3: A Realistic and Fun Driving Simulator</h1>
|
3 |
-
<p>Do you love driving cars and parking them in challenging spots? Do you want to experience the thrill of driving different types of vehicles and customizing them to your liking? Do you want to play with your friends and compete with other players online? If you answered yes to any of these questions, then you should try Car Parking Mod APK 4.8.8.3, a modified version of the popular Car Parking game that offers unlimited money, all cars unlocked, multiplayer mode, and more.</p>
|
4 |
-
<h2>What is Car Parking Mod APK 4.8.8.3?</h2>
|
5 |
-
<p>Car Parking is a realistic and fun driving simulator game that tests your skills in parking various cars in different scenarios. You can choose from over 100 cars, ranging from sedans, SUVs, sports cars, trucks, buses, and even police cars. You can also customize your cars with different colors, wheels, spoilers, stickers, and more.</p>
|
6 |
-
<h2>car parking mod apk 4.8.8.3</h2><br /><p><b><b>Download File</b> ⚹ <a href="https://urlin.us/2uSTZM">https://urlin.us/2uSTZM</a></b></p><br /><br />
|
7 |
-
<p>The game has over 200 levels, each with its own difficulty and objectives. You have to park your car in the designated spot without hitting any obstacles or other cars. You also have to follow the traffic rules and signals, such as speed limits, stop signs, traffic lights, etc.</p>
|
8 |
-
<p>Car Parking Mod APK 4.8.8.3 is a modified version of the original game that gives you access to unlimited money, all cars unlocked, multiplayer mode, and more features that make the game more enjoyable and exciting.</p>
|
9 |
-
<h3>Features of Car Parking Mod APK 4.8.8.3</h3>
|
10 |
-
<h4>Unlimited Money</h4>
|
11 |
-
<p>With Car Parking Mod APK 4.8.8.3, you don't have to worry about running out of money to buy new cars or upgrade them. You can get unlimited money by completing levels or by using the in-game shop.</p>
|
12 |
-
<h4>All Cars Unlocked</h4>
|
13 |
-
<p>With Car Parking Mod APK 4.8.8.3, you don't have to wait to unlock new cars or spend money to buy them. You can access all the cars in the game from the start and choose whichever one you like.</p>
|
14 |
-
<h4>Multiplayer Mode</h4>
|
15 |
-
<p>With Car Parking Mod APK 4.8.8.3, you don't have to play alone or against the computer. You can play with your friends or other players online in multiplayer mode. You can join or create rooms and chat with other players while playing.</p>
|
16 |
-
<p>car parking multiplayer mod apk v4.8.8.3 unlimited money<br />
|
17 |
-
car parking multiplayer mod apk v4.8.8.3 download for android<br />
|
18 |
-
car parking multiplayer mod apk v4.8.8.3 latest version<br />
|
19 |
-
car parking multiplayer mod apk v4.8.8.3 free shopping<br />
|
20 |
-
car parking multiplayer mod apk v4.8.8.3 unlocked all cars<br />
|
21 |
-
car parking multiplayer mod apk v4.8.8.3 no root<br />
|
22 |
-
car parking multiplayer mod apk v4.8.8.3 online<br />
|
23 |
-
car parking multiplayer mod apk v4.8.8.3 hack<br />
|
24 |
-
car parking multiplayer mod apk v4.8.8.3 gameplay<br />
|
25 |
-
car parking multiplayer mod apk v4.8.8.3 review<br />
|
26 |
-
car parking multiplayer mod apk v4.8.8.3 update<br />
|
27 |
-
car parking multiplayer mod apk v4.8.8.3 new features<br />
|
28 |
-
car parking multiplayer mod apk v4.8.8.3 cheats<br />
|
29 |
-
car parking multiplayer mod apk v4.8.8.3 how to install<br />
|
30 |
-
car parking multiplayer mod apk v4.8.8.3 best settings<br />
|
31 |
-
car parking multiplayer mod apk v4.8.8.3 tips and tricks<br />
|
32 |
-
car parking multiplayer mod apk v4.8.8.3 custom cars<br />
|
33 |
-
car parking multiplayer mod apk v4.8.8.3 realistic graphics<br />
|
34 |
-
car parking multiplayer mod apk v4.8.8.3 high quality open world<br />
|
35 |
-
car parking multiplayer mod apk v4.8.8.3 fun gameplay<br />
|
36 |
-
car parking multiplayer mod apk v4.8.8.3 82 real-life challenges<br />
|
37 |
-
car parking multiplayer mod apk v4.8.8.3 different vehicles<br />
|
38 |
-
car parking multiplayer mod apk v4.8.8.3 interior buildings<br />
|
39 |
-
car parking multiplayer mod apk v4.8.8.3 dynamic vinyls<br />
|
40 |
-
car parking multiplayer mod apk v4 . 88 . 83 vision auto tungsten<br />
|
41 |
-
car parking multiplayer mod apk v4 . 88 . 83 highly detailed environments<br />
|
42 |
-
car parking multiplayer mod apk v4 . 88 . 83 100 cars with real interiors<br />
|
43 |
-
car parking multiplayer mod apk v4 . 88 . 83 16 player skins<br />
|
44 |
-
car parking multiplayer mod apk v4 . 88 . 83 trailers, pickups, trucks, sports and classic cars<br />
|
45 |
-
car parking multiplayer mod apk v4 . 88 . 83 voice chat with friends<br />
|
46 |
-
car parking multiplayer mod apk v4 . 88 . 83 exchange cars with real players<br />
|
47 |
-
car parking multiplayer mod apk v4 . 88 . 83 police mode with sirens and radar<br />
|
48 |
-
car parking multiplayer mod apk v4 . 88 . 83 manual transmission with clutch and gear shift<br />
|
49 |
-
car parking multiplayer mod apk v4 . 88 . 83 engine tuning and performance upgrades<br />
|
50 |
-
car parking multiplayer mod apk v4 . 88 . 83 body parts and accessories customization<br />
|
51 |
-
car parking multiplayer mod apk v4 . 88 . 83 realistic physics and sound effects </p>
|
52 |
-
<h4>Customization Options</h4>
|
53 |
-
<p>With Car Parking Mod APK 4.8.8.3, you don't have to settle for the default appearance of your cars. You can customize them with different colors, wheels, spoilers, stickers, and more.</p>
|
54 |
-
<h4>Realistic Physics and Graphics</h4>
|
55 |
-
<p>With Car Parking Mod APK 4.8.8.3, you don't have to compromise on the quality of the game's physics and graphics. The game has realistic physics that simulate the behavior of real cars and their interaction with the environment.</p>
|
56 |
-
<p>The game also has high-quality graphics that create a realistic and immersive atmosphere for the game.</p>
|
57 |
-
<h3>How to Download and Install Car Parking Mod APK 4.8.8.3?</h3>
|
58 |
-
<p>If you want to download and install Car Parking Mod APK 4 .8.3, you need to follow these simple steps:</p>
|
59 |
-
<h4>Step 1: Enable Unknown Sources</h4>
|
60 |
-
<p>Before you can install any modded or third-party app on your Android device, you need to enable the option of unknown sources in your settings. This will allow you to install apps from sources other than the Google Play Store.</p>
|
61 |
-
<p>To enable unknown sources, go to your device's settings, then security, then unknown sources, and toggle it on.</p>
|
62 |
-
<h4>Step 2: Download the APK File</h4>
|
63 |
-
<p>Next, you need to download the APK file of Car Parking Mod APK 4.8.8.3 from a reliable and trusted source. You can use the link below to download the file directly to your device.</p>
|
64 |
-
<p><a href="">Download Car Parking Mod APK 4.8.8.3 here</a></p>
|
65 |
-
<h4>Step 3: Install the APK File</h4>
|
66 |
-
<p>Once you have downloaded the APK file, you need to install it on your device. To do this, locate the file in your device's storage and tap on it. You will see a prompt asking you to confirm the installation. Tap on install and wait for the process to finish.</p>
|
67 |
-
<h4>Step 4: Enjoy the Game</h4>
|
68 |
-
<p>After the installation is complete, you can launch the game from your app drawer or home screen and enjoy the game with all its features.</p>
|
69 |
-
<h2>Pros and Cons of Car Parking Mod APK 4.8.8.3</h2>
|
70 |
-
<p>Car Parking Mod APK 4.8.8.3 is a great game for anyone who loves driving and parking games, but it also has some pros and cons that you should be aware of before playing it.</p>
|
71 |
-
<h3>Pros</h3>
|
72 |
-
<ul>
|
73 |
-
<li>The game is free to download and play.</li>
|
74 |
-
<li>The game has unlimited money, all cars unlocked, multiplayer mode, and more features that make it more fun and exciting.</li>
|
75 |
-
<li>The game has realistic physics and graphics that create a realistic and immersive atmosphere for the game.</li>
|
76 |
-
<li>The game has over 200 levels, each with its own difficulty and objectives.</li>
|
77 |
-
<li>The game has over 100 cars, ranging from sedans, SUVs, sports cars, trucks, buses, and even police cars.</li>
|
78 |
-
<li>The game has customization options that allow you to change the appearance of your cars with different colors, wheels, spoilers, stickers, and more.</li>
|
79 |
-
</ul>
|
80 |
-
<h3>Cons</h3>
|
81 |
-
<ul>
|
82 |
-
<li>The game may not be compatible with some devices or Android versions.</li>
|
83 |
-
<li>The game may have some bugs or glitches that affect its performance or gameplay.</li>
|
84 |
-
<li>The game may require a stable internet connection for multiplayer mode or some features.</li>
|
85 |
-
<li>The game may not be updated regularly or have new content added.</li>
|
86 |
-
</ul>
|
87 |
-
<h2>Conclusion</h2>
|
88 |
-
<p>Car Parking Mod APK 4.8.8.3 is a realistic and fun driving simulator game that tests your skills in parking various cars in different scenarios. The game has unlimited money, all cars unlocked, multiplayer mode, and more features that make it more enjoyable and exciting. The game also has realistic physics and graphics that create a realistic and immersive atmosphere for the game.</p>
|
89 |
-
<p>If you are looking for a driving and parking game that offers a lot of variety, challenge, and fun, then you should try Car Parking Mod APK 4.8.8.3. You can download and install it easily by following the steps above.</p>
|
90 |
-
<p>I hope you enjoyed reading this article and found it helpful. If you have any questions or feedback about Car Parking Mod APK 4.8.8.3, feel free to leave a comment below.</p>
|
91 |
-
<h2>Frequently Asked Questions</h2>
|
92 |
-
<ol>
|
93 |
-
<li><b>What is the difference between Car Parking Mod APK 4.8.8.3 and Car Parking Multiplayer?</b></li>
|
94 |
-
<p>Car Parking Mod APK 4.8.8.3 is a modified version of Car Parking Multiplayer that offers unlimited money, all cars unlocked, multiplayer mode, and more features that make the game more enjoyable and exciting.</p>
|
95 |
-
<li><b>Is Car Parking Mod APK 4.8.8.3 safe to download and install?</b></li>
|
96 |
-
<p>Yes, Car Parking Mod APK 4.8.8.3 is safe to download and install as long as you use a reliable and trusted source like the one provided in this article.</p>
|
97 |
-
<li><b>How can I play Car Parking Mod APK 4 .8.8.3 with my friends?</b></li>
|
98 |
-
<p>You can play Car Parking Mod APK 4.8.8.3 with your friends by using the multiplayer mode. You can join or create rooms and chat with your friends while playing.</p>
|
99 |
-
<li><b>How can I customize my cars in Car Parking Mod APK 4.8.8.3?</b></li>
|
100 |
-
<p>You can customize your cars in Car Parking Mod APK 4.8.8.3 by using the customization options. You can change the color, wheels, spoilers, stickers, and more of your cars.</p>
|
101 |
-
<li><b>How can I get more money in Car Parking Mod APK 4.8.8.3?</b></li>
|
102 |
-
<p>You can get more money in Car Parking Mod APK 4.8.8.3 by completing levels or by using the in-game shop.</p>
|
103 |
-
</ol></p> 197e85843d<br />
|
104 |
-
<br />
|
105 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/CarX Highway Racing APK Hackeado The Best Racing Game on Android.md
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>CarX Highway Racing APK Hackeado: How to Download and Play</h1>
|
3 |
-
<p>If you are a fan of car racing games, you might have heard of CarX Highway Racing. It is a realistic and thrilling game that lets you drive fast cars on highways, evade the police, and compete with other racers. But what if you want to enjoy the game without spending money or worrying about the limitations? That's where CarX Highway Racing APK Hackeado comes in. In this article, we will tell you what CarX Highway Racing is, how to download and install CarX Highway Racing APK Hackeado, why you should play it, and some tips and tricks to help you win the races.</p>
|
4 |
-
<h2>What is CarX Highway Racing?</h2>
|
5 |
-
<p>CarX Highway Racing is a game developed by CarX Technologies, a company that specializes in creating realistic car physics and graphics. The game was released in 2017 for Android and iOS devices, and has since gained millions of downloads and positive reviews. The game features over 40 different cars, from sports cars to muscle cars, that you can customize and upgrade. You can also choose from various game modes, such as campaign, time attack, survival, and online multiplayer. The game also has realistic weather effects, day and night cycles, and dynamic traffic.</p>
|
6 |
-
<h2>carx highway racing apk hackeado</h2><br /><p><b><b>DOWNLOAD</b> ✶ <a href="https://urlin.us/2uT1Ws">https://urlin.us/2uT1Ws</a></b></p><br /><br />
|
7 |
-
<h3>Features of CarX Highway Racing</h3>
|
8 |
-
<p>Some of the features that make CarX Highway Racing stand out from other car racing games are:</p>
|
9 |
-
<ul>
|
10 |
-
<li>Realistic car physics and handling. You can feel the difference between front-wheel drive, rear-wheel drive, and all-wheel drive cars. You can also drift, brake, accelerate, and steer with precision.</li>
|
11 |
-
<li>Stunning graphics and sound effects. The game uses high-quality 3D models, textures, lighting, and shadows to create immersive environments. You can also hear the engine roar, the tires screech, and the police sirens.</li>
|
12 |
-
<li>Challenging gameplay and AI. The game has different difficulty levels, from easy to extreme. You will face smart and aggressive opponents who will try to block your way, ram you off the road, or call for backup. You will also have to deal with traffic jams, roadblocks, and speed traps.</li>
|
13 |
-
<li>Diverse locations and tracks. The game has over 20 locations and 100 tracks to choose from. You can race on highways, city streets, deserts, mountains, forests, and more.</li>
|
14 |
-
</ul>
|
15 |
-
<h3>How to download and install CarX Highway Racing APK Hackeado</h3>
|
16 |
-
<p>If you want to play CarX Highway Racing without any restrictions or costs, you can download and install CarX Highway Racing APK Hackeado. This is a modified version of the game that gives you unlimited money, gold, fuel, and energy. You can use these resources to buy any car you want, upgrade it to the max level, and unlock all the tracks and modes. Here are the steps to download and install CarX Highway Racing APK Hackeado:</p>
|
17 |
-
<ol>
|
18 |
-
<li>Go to [this link](^1^) and download the CarX Highway Racing APK Hackeado file.</li>
|
19 |
-
<li>Go to your device settings and enable the installation of apps from unknown sources.</li>
|
20 |
-
<li>Locate the downloaded file in your file manager and tap on it to install it.</li>
|
21 |
-
<li>Launch the game and enjoy!</li>
|
22 |
-
</ol>
|
23 |
-
<h2>Why play CarX Highway Racing APK Hackeado?</h2>
|
24 |
-
<p>CarX Highway Racing APK Hackeado is not only a fun and exciting game but also a great way to improve your driving skills and reflexes. Here are some of the benefits of playing CarX Highway Racing APK Hackeado:</p>
|
25 |
-
<h3>Benefits of CarX Highway Racing APK Hackeado</h3>
|
26 |
-
<ul>
|
27 |
-
<li>You can save money and time. You don't have to spend real money on in-app purchases or watch ads or wait for timers to refill your resources. You can also save time by skipping the tedious grinding and unlocking everything instantly.</li>
|
28 |
-
<li>You can experiment and have fun. You can try out different cars, upgrades, and strategies without worrying about the consequences. You can also have fun by challenging yourself to beat your own records, outrun the police, or crash into other cars.</li>
|
29 |
-
<li>You can learn and improve. You can learn how to control your car in different situations, such as drifting, braking, accelerating, and steering. You can also improve your reflexes, awareness, and decision-making skills by reacting to the dynamic traffic and environment.</li>
|
30 |
-
</ul>
|
31 |
-
<h3>Tips and tricks for playing CarX Highway Racing APK Hackeado</h3>
|
32 |
-
<p>To make the most out of CarX Highway Racing APK Hackeado, here are some tips and tricks that you can follow:</p>
|
33 |
-
<ul>
|
34 |
-
<li>Choose the right car for the right track. Different cars have different strengths and weaknesses, such as speed, acceleration, handling, and durability. You should choose a car that suits the track's terrain, weather, and traffic conditions.</li>
|
35 |
-
<li>Upgrade your car wisely. You can upgrade your car's engine, transmission, suspension, brakes, tires, and nitro. You should prioritize the upgrades that improve your car's performance and stability.</li>
|
36 |
-
<li>Use nitro strategically. Nitro is a powerful boost that can help you gain speed and overtake your opponents. However, it also consumes fuel and makes your car harder to control. You should use nitro when you have a clear road ahead of you, or when you need to escape from the police or catch up with the leader.</li>
|
37 |
-
<li>Drift carefully. Drifting is a technique that allows you to turn corners without losing speed. However, it also wears out your tires and makes your car more vulnerable to collisions. You should drift only when necessary, and avoid drifting on slippery or bumpy roads.</li>
|
38 |
-
<li>Avoid collisions and damage. Collisions and damage can slow you down, reduce your fuel and energy, and even end your race. You should avoid hitting other cars, walls, barriers, or obstacles. You should also avoid driving on the wrong side of the road or against the traffic flow.</li>
|
39 |
-
</ul>
|
40 |
-
<h2>Conclusion</h2>
|
41 |
-
<p>CarX Highway Racing APK Hackeado is a great way to enjoy CarX Highway Racing without any limitations or costs. You can download and install CarX Highway Racing APK Hackeado easily and safely from [this link]. You can also benefit from playing CarX Highway Racing APK Hackeado by saving money and time, experimenting and having fun, and learning and improving. You can also follow our tips and tricks to win the races and become the best racer on the highway.</p>
|
42 |
-
<h3>FAQs</h3>
|
43 |
-
<p>Here are some of the frequently asked questions about CarX Highway Racing APK Hackeado:</p>
|
44 |
-
<p>carx highway racing mod apk unlimited money<br />
|
45 |
-
carx highway racing hack apk download<br />
|
46 |
-
carx highway racing apk mod menu<br />
|
47 |
-
carx highway racing cheats apk<br />
|
48 |
-
carx highway racing mod apk latest version<br />
|
49 |
-
carx highway racing hack apk android<br />
|
50 |
-
carx highway racing mod apk obb<br />
|
51 |
-
carx highway racing apk hack 2023<br />
|
52 |
-
carx highway racing mod apk revdl<br />
|
53 |
-
carx highway racing hack apk ios<br />
|
54 |
-
carx highway racing mod apk rexdl<br />
|
55 |
-
carx highway racing hack apk 1.74.8<br />
|
56 |
-
carx highway racing mod apk offline<br />
|
57 |
-
carx highway racing hack apk free download<br />
|
58 |
-
carx highway racing mod apk no root<br />
|
59 |
-
carx highway racing hack apk online<br />
|
60 |
-
carx highway racing mod apk data<br />
|
61 |
-
carx highway racing hack apk unlimited gold<br />
|
62 |
-
carx highway racing mod apk all cars unlocked<br />
|
63 |
-
carx highway racing hack apk no verification<br />
|
64 |
-
carx highway racing mod apk pure<br />
|
65 |
-
carx highway racing hack apk 2022<br />
|
66 |
-
carx highway racing mod apk happymod<br />
|
67 |
-
carx highway racing hack apk latest<br />
|
68 |
-
carx highway racing mod apk android 1</p>
|
69 |
-
<ol>
|
70 |
-
<li>Is CarX Highway Racing APK Hackeado safe to download and install?</li>
|
71 |
-
<p>Yes, CarX Highway Racing APK Hackeado is safe to download and install. It does not contain any viruses, malware, or spyware. It also does not require any root or jailbreak access to your device.</p>
|
72 |
-
<li>Is CarX Highway Racing APK Hackeado compatible with my device?</li>
|
73 |
-
<p>CarX Highway Racing APK Hackeado is compatible with most Android devices that have Android 4.1 or higher. However, some devices may experience performance issues or crashes due to hardware limitations or compatibility issues.</p>
|
74 |
-
<li>How do I update CarX Highway Racing APK Hackeado?</li>
|
75 |
-
<p>To update CarX Highway Racing APK Hackeado, you need to download and install the latest version of CarX Highway Racing APK Hackeado from [this link]. You do not need to uninstall the previous version of CarX Highway Racing APK Hackeado before installing the new one.</p>
|
76 |
-
<li>Can I play CarX Highway Racing APK Hackeado online with other players?</li>
|
77 |
-
<p>Yes, you can play CarX Highway Racing APK Hackeado online with other players who have CarX Highway Racing APK Hackeado installed on their devices. However, you may not be able to play online with players who have the original version of CarX Highway Racing installed on their devices.</p>
|
78 |
-
<li>Can I get banned for playing CarX Highway Racing APK Hackeado?</li>
|
79 |
-
<p>No, you will not get banned for playing CarX Highway Racing APK Hackeado. The game does not have any anti-cheat system or detection mechanism that can identify or ban players who use CarX Highway Racing APK Hackeado.</p>
|
80 |
-
</ol></p> 197e85843d<br />
|
81 |
-
<br />
|
82 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/CarX Street The Best Street Racing Game for Android Users.md
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>How to Download CarX Street on Android</h1>
|
3 |
-
<p>If you are looking for a thrilling racing game that lets you explore a dynamic open world, customize your car, and compete against other players, then you should check out CarX Street. This game is developed by CarX Technologies, the makers of CarX Drift Racing 2, and it offers realistic races on highways and city streets, plus top-speed drift races.</p>
|
4 |
-
<p>In this article, we will show you how to download CarX Street on your Android device and how to play it like a pro. You will learn about the game's features, how to install it from different sources, how to start your racing career, and how to improve your skills and performance.</p>
|
5 |
-
<h2>how to download carx street on android</h2><br /><p><b><b>Download</b> » <a href="https://urlin.us/2uSWJ0">https://urlin.us/2uSWJ0</a></b></p><br /><br />
|
6 |
-
<h2>What is CarX Street?</h2>
|
7 |
-
<p>CarX Street is a free racing game that was released in 2023 as an open beta test. The game is set in Sunset City, a huge open world that you can explore freely with your car. You can join clubs, challenge bosses, buy houses for your cars, and collect parts for your vehicle.</p>
|
8 |
-
<p>The game features realistic physics and controls that make you feel like you are driving a real car. You can customize your car with various parts and accessories, such as mirrors, headlights, lights, skirt, bumper, rims, and more. You can also swap your engine for a different one and upgrade your engine, transmission, body, suspension, and tires.</p>
|
9 |
-
<p>The game has different modes of racing, such as highways, city streets, and drift zones. You can race against other players online or offline, or just cruise around the city at any time of day or night. The game has a dynamic day/night cycle that changes the gameplay and the graphics of the game.</p>
|
10 |
-
<h2>How to Download and Install CarX Street on Android</h2> <p>There are two ways to download and install CarX Street on your Android device: from the Google Play Store or from APK sites. Here are the steps for each method:</p>
|
11 |
-
<h3>Downloading from the Google Play Store</h3>
|
12 |
-
<p>The easiest and safest way to get CarX Street on your Android device is to download it from the Google Play Store. Here is how to do it:</p>
|
13 |
-
<ol>
|
14 |
-
<li>Open the Google Play Store app on your device and search for "CarX Street".</li>
|
15 |
-
<li>Tap on the game icon and then tap on the "Install" button.</li>
|
16 |
-
<li>Wait for the game to download and install on your device. You may need to grant some permissions for the game to run properly.</li>
|
17 |
-
<li>Once the game is installed, you can launch it from your app drawer or home screen.</li>
|
18 |
-
</ol>
|
19 |
-
<h3>Downloading from APK Sites</h3>
|
20 |
-
<p>If you cannot access the Google Play Store or you want to try a different version of the game, you can also download CarX Street from APK sites. However, this method is riskier and may expose your device to malware or viruses. Here are some tips on how to do it safely:</p>
|
21 |
-
<ul>
|
22 |
-
<li>Make sure you have enough storage space on your device for the game and its data files.</li>
|
23 |
-
<li>Enable the option to install apps from unknown sources in your device settings. You can find it under Security or Privacy settings.</li>
|
24 |
-
<li>Find a reputable APK site that offers CarX Street and download the APK file and the OBB file (if any) to your device. Some examples of APK sites are APKPure, APKMirror, and APKMonk.</li>
|
25 |
-
<li>Locate the downloaded files on your device using a file manager app and install the APK file first.</li>
|
26 |
-
<li>If there is an OBB file, copy it to the Android/OBB folder on your device's internal storage or SD card.</li>
|
27 |
-
<li>Launch the game and enjoy.</li>
|
28 |
-
</ul> types of cars available in the game, such as muscle cars, sports cars, supercars, and hypercars. Each car has different stats and performance, such as speed, acceleration, handling, and drift. You can also see the price and the rarity of each car.</p>
|
29 |
-
<p>How to install carx street on android device<br />
|
30 |
-
Carx street android download guide<br />
|
31 |
-
Steps to download carx street for android phone<br />
|
32 |
-
Carx street apk download for android<br />
|
33 |
-
How to get carx street on android tablet<br />
|
34 |
-
Carx street android game free download<br />
|
35 |
-
Download carx street from google play store<br />
|
36 |
-
How to play carx street on android<br />
|
37 |
-
Carx street android beta download<br />
|
38 |
-
Carx street open world racing game for android<br />
|
39 |
-
How to update carx street on android<br />
|
40 |
-
Carx street android download link<br />
|
41 |
-
Carx street android requirements and compatibility<br />
|
42 |
-
How to fix carx street download error on android<br />
|
43 |
-
Carx street android gameplay and review<br />
|
44 |
-
Download carx street mod apk for android<br />
|
45 |
-
How to uninstall carx street from android<br />
|
46 |
-
Carx street android tips and tricks<br />
|
47 |
-
Carx street android latest version download<br />
|
48 |
-
How to backup carx street data on android<br />
|
49 |
-
Carx street android offline download<br />
|
50 |
-
How to join carx street beta test on android<br />
|
51 |
-
Carx street android cheats and hacks<br />
|
52 |
-
Download carx street xapk file for android<br />
|
53 |
-
How to transfer carx street progress to another android device<br />
|
54 |
-
Carx street android graphics settings and optimization<br />
|
55 |
-
How to stream carx street on android<br />
|
56 |
-
Carx street android controller support and configuration<br />
|
57 |
-
Download carx street obb file for android<br />
|
58 |
-
How to change language in carx street on android<br />
|
59 |
-
Carx street android multiplayer mode and features<br />
|
60 |
-
How to redeem codes in carx street on android<br />
|
61 |
-
Carx street android best cars and tuning options<br />
|
62 |
-
Download carx street from apkcombo for android<br />
|
63 |
-
How to record carx street gameplay on android<br />
|
64 |
-
Carx street android sound and music settings<br />
|
65 |
-
How to contact carx street support service on android<br />
|
66 |
-
Carx street android in-app purchases and prices<br />
|
67 |
-
Download carx street from filehippo for android<br />
|
68 |
-
How to enable notifications for carx street on android<br />
|
69 |
-
Carx street android drift mode and controls<br />
|
70 |
-
How to clear cache for carx street on android<br />
|
71 |
-
Carx street android clubs and challenges <br />
|
72 |
-
Download carx street from apkpure for android <br />
|
73 |
-
How to share carx street screenshots on android <br />
|
74 |
-
Carx street android gas stations and fuel types <br />
|
75 |
-
How to disable ads in carx street on android <br />
|
76 |
-
Carx street android license agreement and privacy policy <br />
|
77 |
-
Download carx street from uptodown for android <br />
|
78 |
-
How to rate and review carx street on google play store</p>
|
79 |
-
<p>You can customize your car with various parts and accessories, such as mirrors, headlights, lights, skirt, bumper, rims, and more. You can also change the color, the vinyl, the license plate, and the stickers of your car. To customize your car, you need to use coins or diamonds, which are the in-game currencies.</p>
|
80 |
-
<h3>Joining a Club</h3>
|
81 |
-
<p>One of the best features of CarX Street is that you can join or create a club with other players. A club is a group of racers that share a common name, logo, and chat. You can join a club by searching for its name or by accepting an invitation from another player. You can also create your own club by choosing a name, a logo, and a description.</p>
|
82 |
-
<p>Joining a club has many benefits for your racing career. You can chat with other club members, share tips and tricks, and challenge them to friendly races. You can also participate in club events and missions, which are special races that reward you with coins, diamonds, parts, and reputation points. Reputation points are used to rank up your club and unlock new perks and rewards.</p>
|
83 |
-
<h3>Racing Against Other Players</h3>
|
84 |
-
<p>The main mode of CarX Street is racing against other players online or offline. You can choose from different modes of racing, such as highways, city streets, and drift zones. Each mode has different rules and objectives, such as reaching the finish line first, earning the most points by drifting, or escaping from the police.</p>
|
85 |
-
<p>To start a race, you need to open the map and select a location. You can see the difficulty level, the entry fee, and the reward for each location. You can also see the number of players online and offline in each location. You can join an existing race or create your own race by choosing the number of laps, the time limit, and the weather conditions.</p>
|
86 |
-
<p>Once you join a race, you need to use your skills and strategy to win. You can use the gas pedal, the brake pedal, the handbrake, and the nitro boost to control your car. You can also use the steering wheel or the tilt option to steer your car. You need to avoid crashing into obstacles or other cars, as this will damage your car and slow you down.</p>
|
87 |
-
<h3>Drifting</h3>
|
88 |
-
<p>One of the most fun and challenging aspects of CarX Street is drifting. Drifting is a technique that involves sliding your car sideways while maintaining control and speed. Drifting is useful for taking sharp turns without losing momentum and for earning points and rewards.</p>
|
89 |
-
<p>To drift in CarX Street, you need to use the handbrake or the brake pedal while turning your car. You need to balance your throttle and steering to maintain your drift angle and direction. You also need to avoid hitting walls or other cars while drifting, as this will end your drift combo.</p>
|
90 |
-
<p>Drifting is important for earning points and rewards in CarX Street. The more you drift, the more points you get. The points are multiplied by your drift combo, which is the number of consecutive drifts you perform without interruption. The points are also affected by your drift angle, speed, distance, and style.</p>
|
91 |
-
<p>You can use your drift points to buy new cars or parts for your car. You can also use them to unlock new locations or events in the game. Drifting is also essential for completing some missions or challenges in the game.</p> <h2>How to Improve Your Skills and Performance in CarX Street</h2>
|
92 |
-
<p>If you want to become a better racer and a legend of Sunset City, you need to improve your skills and performance in CarX Street. Here are some advanced tips on how to do that:</p>
|
93 |
-
<h3>Upgrading Your Car</h3>
|
94 |
-
<p>One of the best ways to improve your car's performance is to upgrade it with part tuning. Part tuning is a feature that allows you to unlock the full potential of your car and improve its engine, transmission, body, suspension, and tires. You can access part tuning from the garage menu.</p>
|
95 |
-
<p>To use part tuning, you need to have parts for your car. You can get parts by winning races, completing missions, or buying them with coins or diamonds. You can also get parts by dismantling other cars or parts that you don't need.</p>
|
96 |
-
<p>Once you have parts, you can use them to upgrade your car's stats. You can see the current and the maximum stats of your car on the part tuning screen. You can also see the effect of each part on your car's performance. You can upgrade your car's stats up to 100%, but you need to have enough parts and coins for that.</p>
|
97 |
-
<h3>Swapping Your Engine</h3>
|
98 |
-
<p>Another way to improve your car's performance is to swap your engine for a different one. Engine swapping is a feature that allows you to change your car's engine type and power. You can access engine swapping from the garage menu.</p>
|
99 |
-
<p>To use engine swapping, you need to have engines for your car. You can get engines by winning races, completing missions, or buying them with coins or diamonds. You can also get engines by dismantling other cars or engines that you don't need.</p>
|
100 |
-
<p>Once you have engines, you can use them to swap your car's engine. You can see the current and the available engines for your car on the engine swapping screen. You can also see the effect of each engine on your car's performance. You can swap your car's engine as many times as you want, but you need to have enough engines and coins for that.</p>
|
101 |
-
<p>Engine swapping has advantages and disadvantages for your car's performance. Some engines may increase your car's speed, acceleration, or drift, but they may also decrease your car's handling, stability, or fuel efficiency. You need to choose the engine that suits your racing style and preference.</p>
|
102 |
-
<h3>Using the Right Fuel</h3>
|
103 |
-
<p>A third way to improve your car's performance is to use the right fuel for your car. Fuel is a resource that affects your car's speed, acceleration, and nitro boost. You can see your car's fuel level on the top left corner of the screen during a race.</p>
|
104 |
-
<p>To use fuel, you need to have fuel for your car. You can get fuel by visiting gas stations in the city or by buying them with coins or diamonds. You can also get fuel by completing missions or challenges in the game.</p>
|
105 |
-
<p>Once you have fuel, you can use it to fill up your car's tank. You can see the current and the maximum fuel level of your car on the fuel screen. You can also see the effect of each fuel type on your car's performance. You can fill up your car's tank as much as you want, but you need to have enough fuel and coins for that.</p>
|
106 |
-
<p>Fuel has different types and qualities that affect your car's performance. Some fuel types may increase your car's speed, acceleration, or nitro boost, but they may also decrease your car's handling, stability, or durability. You need to choose the fuel type that suits your racing style and preference.</p>
|
107 |
-
<h3>Racing at Different Times of Day</h3>
|
108 |
-
<p>A fourth way to improve your skills and performance in CarX Street is to race at different times of day. The game has a dynamic day/night cycle that changes the gameplay and the graphics of the game.</p>
|
109 |
-
<p>The time of day affects the visibility, the traffic, and the difficulty of the races. During the day, you can see more clearly, but there are more cars and pedestrians on the road. During the night, you can see less clearly, but there are fewer cars and pedestrians on the road.</p>
|
110 |
-
<p>The time of day also affects the atmosphere and the mood of the game. During the day, you can enjoy the bright colors and the sunny weather of Sunset City. During the night, you can admire the neon lights and the dark sky of Sunset City.</p>
|
111 |
-
<p>You can change the time of day by using a clock icon on the map screen. You can choose between morning, afternoon, evening, and night. You can also let the time of day change naturally as you play.</p>
|
112 |
-
<h2>Conclusion</h2>
|
113 |
-
<p>CarX Street is an amazing racing game that lets you experience the thrill of racing and drifting in a realistic open world. You can download and install it on your Android device from the Google Play Store or from APK sites. You can also play it like a pro by choosing a car, joining a club, racing against other players, and drifting. You can also improve your skills and performance by upgrading your car, swapping your engine, using the right fuel, and racing at different times of day.</p>
|
114 |
-
<p>If you are a fan of racing games, you should not miss CarX Street. It is one of the best racing games for Android that offers stunning graphics, realistic physics, and endless fun. Download it now and join the millions of players who are enjoying CarX Street.</p>
|
115 |
-
<h2>FAQs</h2>
|
116 |
-
<p>Here are some frequently asked questions about CarX Street:</p>
|
117 |
-
<ol>
|
118 |
-
<li>How can I get more coins and diamonds in CarX Street?</li>
|
119 |
-
<p>You can get more coins and diamonds by winning races, completing missions, participating in club events, watching ads, or buying them with real money.</p>
|
120 |
-
<li>How can I unlock new cars or parts in CarX Street?</li>
|
121 |
-
<p>You can unlock new cars or parts by earning reputation points, which are used to rank up your level and unlock new rewards. You can also buy them with coins or diamonds.</p>
|
122 |
-
<li>How can I drift better in CarX Street?</li>
|
123 |
-
<p>You can drift better by using the handbrake or the brake pedal while turning your car. You also need to balance your throttle and steering to maintain your drift angle and direction. You can also use the drift assist option to help you drift easier.</p>
|
124 |
-
<li>How can I race with my friends in CarX Street?</li>
|
125 |
-
<p>You can race with your friends by joining or creating a club and inviting them to join. You can also challenge them to friendly races or join their races from the map screen.</p>
|
126 |
-
<li>How can I change the camera view in CarX Street?</li>
|
127 |
-
<p>You can change the camera view by tapping on the camera icon on the top right corner of the screen during a race. You can choose between different views, such as cockpit, hood, bumper, chase, or far chase.</p>
|
128 |
-
</ol></p> 197e85843d<br />
|
129 |
-
<br />
|
130 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1phancelerku/anime-remove-background/CSR Racing 2 MOD APK The Ultimate Fast and Furious Racing Game for Android.md
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>CSR Racing 2 Fast and Furious Mod APK: Everything You Need to Know</h1>
|
3 |
-
<p>If you are a fan of racing games, you have probably heard of CSR Racing 2, one of the most popular and realistic games in the genre. And if you are a fan of Fast and Furious, you have probably been excited by the recent collaboration between the game and the movie franchise, bringing exclusive cars and challenges to the game. But what if you want to enjoy the game without any limitations or restrictions? That's where CSR Racing 2 Mod APK comes in. In this article, we will tell you everything you need to know about this modified version of the game, how to install it, and what benefits it offers.</p>
|
4 |
-
<h2>What is CSR Racing 2?</h2>
|
5 |
-
<p>CSR Racing 2 is a racing game developed by NaturalMotionGames Ltd and released in 2016. It is the sequel to CSR Racing, which was released in 2012. The game features stunning graphics, realistic physics, and immersive gameplay that make you feel like you are driving a real car. You can customize your car with various parts, paint jobs, decals, and more. You can also collect and upgrade over 200 licensed cars from top brands like Ferrari, Lamborghini, Bugatti, McLaren, and more.</p>
|
6 |
-
<h2>csr racing 2 fast and furious mod apk</h2><br /><p><b><b>Download File</b> ✫ <a href="https://jinyurl.com/2uNOXw">https://jinyurl.com/2uNOXw</a></b></p><br /><br />
|
7 |
-
<h3>A realistic racing game with stunning graphics and gameplay</h3>
|
8 |
-
<p>One of the main attractions of CSR Racing 2 is its graphics. The game uses a cutting-edge 3D rendering technique called PBR (Physically Based Rendering) that creates realistic lighting, shadows, reflections, and textures. The cars look amazing, with detailed interiors, exteriors, and engine sounds. The tracks are also diverse and realistic, ranging from urban streets to desert roads. The gameplay is also smooth and responsive, with easy controls and realistic physics. You can choose from different modes, such as drag races, crew battles, ladder races, regulation races, and more.</p>
|
9 |
-
<h3>A huge collection of licensed cars from top brands</h3>
|
10 |
-
<p>Another attraction of CSR Racing 2 is its car collection. The game features over 200 licensed cars from top brands like Ferrari, Lamborghini, Bugatti, McLaren, and more. You can collect them by winning races, opening crates, or buying them with in-game currency. You can also upgrade them with various parts, such as engines, turbochargers, nitrous oxide systems, tires, transmissions, and more. You can also customize them with various paint jobs, decals, rims, spoilers, and more.</p>
|
11 |
-
<h3>A competitive online mode with real-time races and events</h3>
|
12 |
-
<p>The game also has a competitive online mode where you can race against other players from around the world in real-time. You can join or create a crew with your friends or other players and compete in crew battles, leaderboards, chat rooms, and more. You can also participate in various events that offer rewards and prizes for completing missions or reaching milestones. Some of the events are seasonal or limited-time only, so you have to be quick to join them.</p>
|
13 |
-
<h2>What is Fast and Furious?</h2>
|
14 |
-
<p>Fast and Furious is a popular movie franchise that features street racing and heists. The franchise started in 2001 with The Fast <h2>What is Fast and Furious?</h2>
|
15 |
-
<p>Fast and Furious is a popular movie franchise that features street racing and heists. The franchise started in 2001 with The Fast and the Furious, and has since released nine more movies, with the latest one being F9: The Fast Saga. The movies star Vin Diesel, Paul Walker, Michelle Rodriguez, Tyrese Gibson, Dwayne Johnson, Jason Statham, and many other actors. The movies are known for their thrilling action scenes, exotic locations, and diverse cast of characters.</p>
|
16 |
-
<h3>A popular movie franchise featuring street racing and heists</h3>
|
17 |
-
<p>The main plot of the Fast and Furious movies revolves around Dominic Toretto (Vin Diesel), a former street racer who leads a crew of skilled drivers and criminals. He is often pursued by law enforcement agents, such as Brian O'Conner (Paul Walker), who later becomes his friend and ally. Together, they face various enemies and challenges, such as drug lords, terrorists, hackers, and rogue agents. Along the way, they also form a family bond with each other and their loyal friends.</p>
|
18 |
-
<h3>A collaboration with CSR Racing 2 to bring exclusive cars and challenges</h3>
|
19 |
-
<p>In 2019, CSR Racing 2 partnered with Fast and Furious to bring some of the iconic cars from the movies to the game. Players can race with cars such as the Toyota Supra, the Veilside Mazda RX-7, the Mitsubishi Eclipse, and many more. They can also participate in special events that are inspired by the movies, such as the Hobbs & Shaw event, the Fate of the Furious event, and the Fast & Furious Finale event. These events offer rewards and prizes for completing missions or reaching milestones.</p>
|
20 |
-
<h3>A limited-time event with rewards and prizes for completing missions</h3>
|
21 |
-
<p>The latest event in CSR Racing 2 is the Fast & Furious Finale event, which celebrates the release of F9: The Fast Saga. The event runs from April 15 to June 30, 2021, and features eight cars from the movie. Players can race with cars such as the Dodge Charger Daytona, the Veilside Honda S2000, Jesse's Volkswagen Jetta, and more. They can also unlock exclusive liveries, decals, and parts for their cars. The event also has a storyline that follows the movie's plot and characters.</p>
|
22 |
-
<p>csr racing 2 mod apk unlimited money and keys<br />
|
23 |
-
csr racing 2 fast and furious cars mod apk<br />
|
24 |
-
csr racing 2 mod apk latest version download<br />
|
25 |
-
csr racing 2 mod apk offline mode<br />
|
26 |
-
csr racing 2 mod apk unlimited gold and cash<br />
|
27 |
-
csr racing 2 fast and furious flip car mod apk<br />
|
28 |
-
csr racing 2 mod apk all cars unlocked<br />
|
29 |
-
csr racing 2 mod apk no root required<br />
|
30 |
-
csr racing 2 mod apk free shopping<br />
|
31 |
-
csr racing 2 fast and furious jetta mod apk<br />
|
32 |
-
csr racing 2 mod apk unlimited nitro<br />
|
33 |
-
csr racing 2 fast and furious supra mod apk<br />
|
34 |
-
csr racing 2 mod apk anti ban<br />
|
35 |
-
csr racing 2 mod apk unlimited fuel<br />
|
36 |
-
csr racing 2 fast and furious charger mod apk<br />
|
37 |
-
csr racing 2 mod apk mega mod<br />
|
38 |
-
csr racing 2 fast and furious events mod apk<br />
|
39 |
-
csr racing 2 mod apk unlimited rp<br />
|
40 |
-
csr racing 2 mod apk no ads<br />
|
41 |
-
csr racing 2 fast and furious skyline mod apk<br />
|
42 |
-
csr racing 2 mod apk obb file download<br />
|
43 |
-
csr racing 2 fast and furious honda s2000 mod apk<br />
|
44 |
-
csr racing 2 mod apk unlimited everything<br />
|
45 |
-
csr racing 2 mod apk high graphics<br />
|
46 |
-
csr racing 2 fast and furious eclipse mod apk<br />
|
47 |
-
csr racing 2 mod apk ios download<br />
|
48 |
-
csr racing 2 fast and furious plymouth roadrunner mod apk<br />
|
49 |
-
csr racing 2 mod apk unlocked premium features<br />
|
50 |
-
csr racing 2 mod apk unlimited crew points<br />
|
51 |
-
csr racing 2 fast and furious mitsubishi lancer evolution vii mod apk<br />
|
52 |
-
csr racing 2 mod apk online multiplayer<br />
|
53 |
-
csr racing 2 fast and furious dodge challenger srt demon mod apk<br />
|
54 |
-
csr racing 2 mod apk unlimited rare imports<br />
|
55 |
-
csr racing 2 mod apk custom cars<br />
|
56 |
-
csr racing 2 fast and furious nissan silvia s15 mona lisa mod apk<br />
|
57 |
-
csr racing 2 mod apk unlimited fusion parts<br />
|
58 |
-
csr racing 2 fast and furious lamborghini murcielago lp640 mod apk<br />
|
59 |
-
csr racing 2 mod apk unlimited legendary keys<br />
|
60 |
-
csr racing 2 mod apk realistic physics<br />
|
61 |
-
csr racing 2 fast and furious ford gt40 mk ii mod apk</p>
|
62 |
-
<h2>What is CSR Racing 2 Mod APK?</h2>
|
63 |
-
<p>CSR Racing 2 Mod APK is a modified version of the original game that unlocks everything. It is a way to enjoy the game without spending money or waiting for upgrades. It is also a risk-free download that does not require rooting or jailbreaking your device.</p>
|
64 |
-
<h3>A modified version of the original game that unlocks everything</h3>
|
65 |
-
<p>With CSR Racing 2 Mod APK, you can access all the features and content of the game without any limitations or restrictions. You can get unlimited money, keys, gold, fuel, and cash to buy or upgrade any car you want. You can also unlock all the cars, tracks, modes, events, and customizations that are otherwise locked or premium. You can also bypass any ads or verification processes that might interrupt your gameplay.</p>
|
66 |
-
<h3>A way to enjoy the game without spending money or waiting for upgrades</h3>
|
67 |
-
<p>One of the drawbacks of playing CSR Racing 2 is that it can be quite expensive and time-consuming to progress in the game. You need to spend real money or earn in-game currency to buy or upgrade your cars. You also need to wait for your fuel to refill or your parts to be delivered. This can be frustrating and boring for some players who want to enjoy the game without any hassle. With CSR Racing 2 Mod APK, you don't have to worry about any of these issues. You can play the game at your own pace and style without any pressure or cost.</p>
|
68 |
-
<h3>A risk-free download that does not require rooting or jailbreaking your device</h3>
|
69 |
-
<p>Some modded games require you to root or jailbreak your device in order to install them. This can be risky and harmful for your device's security and performance. It can also void your warranty or cause compatibility issues with other apps. With CSR Racing 2 Mod APK, you don't have to do any of these things. You can simply download the mod apk file from a trusted source and install it on your device without any problem. You can also uninstall it anytime you want without any consequences.</p> <h2>How to Install CSR Racing 2 Mod APK?</h2>
|
70 |
-
<p>If you are interested in trying out CSR Racing 2 Mod APK, you might be wondering how to install it on your device. Don't worry, it's very easy and simple. Just follow these steps and you will be ready to race in no time.</p>
|
71 |
-
<h3>Step 1: Download the mod apk file from a trusted source</h3>
|
72 |
-
<p>The first thing you need to do is to download the mod apk file from a trusted source. You can find many websites that offer the mod apk file, but be careful and choose a reliable one. Some websites might have fake or malicious files that can harm your device or steal your data. To avoid any risk, you can use this link to download the mod apk file. This is a safe and verified source that has been tested and reviewed by many users.</p>
|
73 |
-
<h3>Step 2: Enable unknown sources in your device settings</h3>
|
74 |
-
<p>The next thing you need to do is to enable unknown sources in your device settings. This is a security feature that prevents you from installing apps that are not from the official app store. Since the mod apk file is not from the app store, you need to enable this option to install it. To do this, go to your device settings and look for the security or privacy option. Then, find the unknown sources option and toggle it on. You might see a warning message, but don't worry, it's safe to proceed.</p>
|
75 |
-
<h3>Step 3: Install the mod apk file and launch the game</h3>
|
76 |
-
<p>The final thing you need to do is to install the mod apk file and launch the game. To do this, go to your file manager and locate the mod apk file that you downloaded. Tap on it and follow the instructions to install it. It might take a few seconds or minutes depending on your device. Once it's done, you can launch the game from your app drawer or home screen. You will see the CSR Racing 2 logo and then the game will load. You can now enjoy the game with all the features and content unlocked.</p>
|
77 |
-
<h2>Conclusion</h2>
|
78 |
-
<p>CSR Racing 2 is one of the best racing games available for mobile devices. It offers realistic graphics, gameplay, and physics that make you feel like you are driving a real car. It also has a huge collection of licensed cars from top brands that you can collect, customize, and upgrade. It also has a competitive online mode where you can race against other players from around the world in real-time. And if you are a fan of Fast and Furious, you can also enjoy the exclusive cars and challenges from the movie franchise.</p>
|
79 |
-
<p>But if you want to enjoy the game without any limitations or restrictions, you can try CSR Racing 2 Mod APK. This is a modified version of the game that unlocks everything for free. You can get unlimited money, keys, gold, fuel, and cash to buy or upgrade any car you want. You can also unlock all the cars, tracks, modes, events, and customizations that are otherwise locked or premium. You can also bypass any ads or verification processes that might interrupt your gameplay.</p>
|
80 |
-
<p>Installing CSR Racing 2 Mod APK is very easy and simple. You just need to download the mod apk file from a trusted source, enable unknown sources in your device settings, and install the mod apk file on your device. You don't need to root or jailbreak your device to do this. You can also uninstall it anytime you want without any consequences.</p>
|
81 |
-
<p>If you are looking for a fun and exciting racing game that offers everything you want, CSR Racing 2 Mod APK is the perfect choice for you. Download it now and start racing with your favorite cars.</p>
|
82 |
-
<h4>FAQs</h4>
|
83 |
-
<p>Here are some frequently asked questions about CSR Racing 2 Mod APK:</p>
|
84 |
-
<ul>
|
85 |
-
<li><b>Is CSR Racing 2 Mod APK safe?</b></li>
|
86 |
-
<p>Yes, CSR Racing 2 Mod APK is safe to use. It does not contain any viruses or malware that can harm your device or steal your data. It also does not require rooting or jailbreaking your device to install it.</p>
|
87 |
-
<li><b>Is CSR Racing 2 Mod APK legal?</b></li>
|
88 |
-
<p>No, CSR Racing 2 Mod APK is not legal. It violates the terms and conditions of the original game and its developers. It also infringes on the intellectual property rights of the car brands and the movie franchise. Using it might result in legal action or account suspension.</p>
|
89 |
-
<li><b>Can I play CSR Racing 2 Mod APK online?</b></li>
|
90 |
-
<p>Yes, you can play CSR Racing 2 Mod APK online with other players from around the world in real-time. However, you might face some issues or errors while playing online, such as connection problems, lag, or cheating. You might also get banned or reported by other players who notice that you are using a modded version of the game.</p>
|
91 |
-
<li><b>Can I update CSR Racing 2 Mod APK?</b></li>
|
92 |
-
<p>No, you cannot update CSR Racing 2 Mod APK. If you try to update it from the app store or the game itself, you will lose all the modded features and content. You will also risk getting detected and banned by the game developers. If you want to update the game, you will have to uninstall the mod apk file and install the original game from the app store.</p>
|
93 |
-
<li><b>Can I use CSR Racing 2 Mod APK with my existing account?</b></li>
|
94 |
-
<p>No, you cannot use CSR Racing 2 Mod APK with your existing account. If you try to log in with your existing account, you will risk getting detected and banned by the game developers. You will also lose all your progress and data on your account. If you want to use the mod apk file, you will have to create a new account or use a guest account.</p>
|
95 |
-
</ul></p> 197e85843d<br />
|
96 |
-
<br />
|
97 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1phancelerku/anime-remove-background/Download PowerShell 2.0 and WinRM 2.0 for Windows XP and Windows Server 2003.md
DELETED
@@ -1,176 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>How to Download PowerShell 2.0</h1>
|
3 |
-
<p>PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. It allows you to perform various operations on your system, such as managing files, processes, services, registry, network, security, and more.</p>
|
4 |
-
<h2>download powershell 2.0</h2><br /><p><b><b>DOWNLOAD</b> ✏ ✏ ✏ <a href="https://jinyurl.com/2uNTng">https://jinyurl.com/2uNTng</a></b></p><br /><br />
|
5 |
-
<p>PowerShell 2.0 was released in October 2009 as part of Windows Management Framework (WMF) for Windows XP, Windows Vista, Windows Server 2003, and Windows Server 2008. It introduced many new features, such as modules, remoting, background jobs, transactions, debugging, eventing, and scripting enhancements.</p>
|
6 |
-
<p>Although newer versions of PowerShell have been released since then, you might need to download PowerShell 2.0 for some reasons. For example, you might have an older script or host program that is incompatible with newer versions of PowerShell or .NET Framework. Or, you might want to run commands or scripts that are designed for PowerShell 2.0 on a different computer that has a newer version of PowerShell installed.</p>
|
7 |
-
<p>In this article, we will show you how to download and install PowerShell 2.0 on different versions of Windows, how to use PowerShell 2.0 commands and scripts, and some tips and recommendations for using PowerShell 2.0.</p>
|
8 |
-
<h2>How to Install PowerShell 2.0 on Different Windows Versions</h2>
|
9 |
-
<p>The installation process of PowerShell 2.0 varies depending on the version of Windows that you have. Here are the steps for installing PowerShell 2.0 on different versions of Windows:</p>
|
10 |
-
<h3>Windows 8.1 and Windows 8</h3>
|
11 |
-
<p>On Windows 8.1 and Windows 8, the PowerShell 2.0 Engine feature is turned on by default. However, to use it, you need to turn on the option for Microsoft .NET Framework 3.5, which it requires. This section also explains how to turn the PowerShell 2.0 Engine feature on and off.</p>
|
12 |
-
<h4>How to turn on .NET Framework 3.5</h4>
|
13 |
-
<ol>
|
14 |
-
<li>On the Start screen, type <strong>Windows Features</strong>.</li>
|
15 |
-
<li>On the Apps bar, click <strong>Settings</strong>, and then click <strong>Turn Windows features on or off</strong>.</li>
|
16 |
-
<li>In the <strong>Windows Features</strong> box, click <strong>.NET Framework</strong> <strong>3.5 (includes .NET</strong> <strong>2.0</strong> <strong>and</strong> <strong>3.0)</strong> to select it. When you select <strong>.NET Framework</strong> <strong>. 3.5 (includes .NET 2.0 and 3.0)</strong>, you also select <strong>Windows PowerShell 2.0 Engine</strong> and <strong>Windows PowerShell Integrated Scripting Environment (ISE)</strong> for .NET Framework 3.5.</li>
|
17 |
-
<li>Click <strong>OK</strong> to install the selected features. You might need to restart your computer after the installation is complete.</li>
|
18 |
-
</ol>
|
19 |
-
<h4>How to turn the PowerShell 2.0 Engine feature on and off</h4>
|
20 |
-
<ol>
|
21 |
-
<li>Follow steps 1 and 2 from the previous section to open the <strong>Windows Features</strong> box.</li>
|
22 |
-
<li>In the <strong>Windows Features</strong> box, expand <strong>.NET Framework</strong> <strong>3.5 (includes .NET</strong> <strong>2.0</strong> <strong>and</strong> <strong>3.0)</strong>, and then select or clear the check box for <strong>Windows PowerShell 2.0 Engine</strong>, depending on whether you want to turn it on or off. You can also select or clear the check box for <strong>Windows PowerShell Integrated Scripting Environment (ISE)</strong> for .NET Framework 3.5, which is a graphical user interface for writing and testing scripts.</li>
|
23 |
-
<li>Click <strong>OK</strong> to apply the changes. You might need to restart your computer after the changes take effect.</li>
|
24 |
-
</ol>
|
25 |
-
<h3>Windows Server 2012 R2 and Windows Server 2012</h3>
|
26 |
-
<p>On Windows Server 2012 R2 and Windows Server 2012, the PowerShell 2.0 Engine feature is not installed by default. However, you can add it by using the Server Manager or the Windows PowerShell cmdlets. This section also explains how to start the PowerShell 2.0 Engine.</p>
|
27 |
-
<h4>How to add the PowerShell 2.0 Engine and .NET Framework 3.5 features</h4>
|
28 |
-
<ol>
|
29 |
-
<li>In Server Manager, click <strong>Add roles and features</strong>.</li>
|
30 |
-
<li>In the <strong>Add Roles and Features Wizard</strong>, click <strong>Next</strong>, and then click <strong>Select a server from the server pool</strong>.</li>
|
31 |
-
<li>Select a server where you want to install the features, and then click <strong>Next</strong>.</li>
|
32 |
-
<li>In the <strong>Select features</strong> page, expand <strong>.NET Framework 3.5 Features</strong>, and then select the check boxes for <strong>.NET Framework 3.5 (includes .NET 2.0 and 3.0)</strong>, <strong>.NET Framework 3.5 (includes .NET 2.0 and 3.0)</strong>, and <strong>.NET Framework 3.5 (includes .NET 2.0 and 3.0)</strong>. When you select these features, you also select the check boxes for <strong>.NET Framework 4.5 Features</strong>, <
|
33 |
-
<strong>.NET Framework 4.5 Features</strong>, and <strong>.NET Framework 4.5 Features</strong>. You can also select or clear the check boxes for other features that you want to install or uninstall.</li>
|
34 |
-
<li>In the same page, expand <strong>User Interfaces and Infrastructure</strong>, and then select or clear the check box for <strong>Powershell ISE (x86)</strong>, depending on whether you want to install or uninstall it. This feature is a graphical user interface for writing and testing scripts that runs on a 32-bit version of Windows PowerShell. If you want to use a 64-bit version of Windows PowerShell ISE, you do not need to install this feature.</li>
|
35 |
-
<li>In the same page, expand <strong>Windows PowerShell</strong>, and then select or clear the check box for <strong>Powershell ISE (x64)</strong>, depending on whether you want to install or uninstall it. This feature is a graphical user interface for writing and testing scripts that runs on a 64-bit version of Windows PowerShell. If you want to use a 32-bit version of Windows PowerShell ISE, you do not need to install this feature.</li>
|
36 |
-
<li>In the same page, expand <strong>Powershell ISE (x64)</strong>, and then select or clear the check box for <
|
37 |
-
<strong>Powershell ISE (x64)</strong>, depending on whether you want to install or uninstall it. This feature is a graphical user interface for writing and testing scripts that runs on a 64-bit version of Windows PowerShell ISE. If you want to use a 32-bit version of Windows PowerShell ISE, you do not need to install this feature.</li>
|
38 |
-
<li>Click <strong>Next</strong>, and then click <strong>Install</strong> to start the installation. You might need to restart your computer after the installation is complete.</li>
|
39 |
-
</ol>
|
40 |
-
<p>You can also use the Windows PowerShell cmdlets to add or remove the PowerShell 2.0 Engine and .NET Framework 3.5 features. For example, you can use the following command to install both features:</p>
|
41 |
-
<code>Install-WindowsFeature -Name Net-Framework-Core,PowerShell-V2</code>
|
42 |
-
<p>You can use the following command to uninstall both features:</p>
|
43 |
-
<p>How to download powershell 2.0 for windows 10<br />
|
44 |
-
Download powershell 2.0 for windows server 2012 r2<br />
|
45 |
-
Download powershell 2.0 for windows xp sp3<br />
|
46 |
-
Download powershell 2.0 for windows vista sp2<br />
|
47 |
-
Download powershell 2.0 for windows server 2008 sp2<br />
|
48 |
-
Download powershell 2.0 for windows server 2003 sp2<br />
|
49 |
-
Download powershell 2.0 and winrm 2.0 for windows update<br />
|
50 |
-
Download powershell 2.0 engine for windows 8.1<br />
|
51 |
-
Download powershell 2.0 engine for windows 8<br />
|
52 |
-
Download powershell 2.0 engine for windows server 2012<br />
|
53 |
-
Download powershell 2.0 engine for windows server 2016<br />
|
54 |
-
Download powershell 2.0 engine for windows server 2019<br />
|
55 |
-
Download powershell 2.0 engine for windows server core<br />
|
56 |
-
Download powershell 2.0 engine for windows management framework<br />
|
57 |
-
Download powershell 2.0 engine for .net framework 3.5<br />
|
58 |
-
Download powershell 2.0 engine for .net framework 4<br />
|
59 |
-
Download powershell 2.0 engine for .net core<br />
|
60 |
-
Download powershell 2.0 engine from microsoft learn<br />
|
61 |
-
Download powershell 2.0 engine from github<br />
|
62 |
-
Download powershell 2.0 engine from microsoft docs<br />
|
63 |
-
Install powershell 2.0 on windows 10<br />
|
64 |
-
Install powershell 2.0 on windows server 2016<br />
|
65 |
-
Install powershell 2.0 on windows server core<br />
|
66 |
-
Install powershell 2.0 on windows management framework<br />
|
67 |
-
Install powershell 2.0 on .net framework 3.5<br />
|
68 |
-
Install powershell 2.0 on .net framework 4<br />
|
69 |
-
Install powershell 2.0 on .net core<br />
|
70 |
-
Install powershell 2.0 from microsoft learn<br />
|
71 |
-
Install powershell 2.0 from github<br />
|
72 |
-
Install powershell 2.0 from microsoft docs<br />
|
73 |
-
Uninstall powershell 3.0 and install powershell 2.0<br />
|
74 |
-
Uninstall powershell 4.0 and install powershell 2.0<br />
|
75 |
-
Uninstall powershell 5.1 and install powershell 2.0<br />
|
76 |
-
Uninstall powershell core and install powershell 2.0<br />
|
77 |
-
Uninstall windows management framework and install powershell 2.0<br />
|
78 |
-
Uninstall .net framework and install powershell 2.0<br />
|
79 |
-
Uninstall .net core and install powershell 2.0<br />
|
80 |
-
Upgrade from powershell v1 to v2 download link<br />
|
81 |
-
Upgrade from cmd to powershell v2 download link<br />
|
82 |
-
Upgrade from bash to powershell v2 download link<br />
|
83 |
-
Run commands in compatibility mode with download link to v1 or v3+<br />
|
84 |
-
Run scripts in compatibility mode with download link to v1 or v3+<br />
|
85 |
-
Run modules in compatibility mode with download link to v1 or v3+<br />
|
86 |
-
Run snap-ins in compatibility mode with download link to v1 or v3+<br />
|
87 |
-
Run providers in compatibility mode with download link to v1 or v3+.</p>
|
88 |
-
<code>Uninstall-WindowsFeature -Name Net-Framework-Core,PowerShell-V2</code>
|
89 |
-
<h4>How to start the PowerShell 2.0 Engine</h4>
|
90 |
-
<p>To start the PowerShell 2.0 Engine, you need to use the <strong>-Version</strong> parameter of the <strong>powershell.exe</strong> command. For example, you can use the following command to start a PowerShell session with the PowerShell 2.0 Engine:</p>
|
91 |
-
<code>powershell.exe -Version 2</code>
|
92 |
-
<p>You can also use the following command to start a Windows PowerShell ISE session with the PowerShell 2.0 Engine:</p>
|
93 |
-
<code>powershell_ise.exe -Version 2</code>
|
94 |
-
<h3>Windows Server 2008 R2, Windows Vista, Windows Server 2003, and Windows XP</h3>
|
95 |
-
<p>On Windows Server 2008 R2, Windows Vista, Windows Server 2003, and Windows XP, the PowerShell 2.0 Engine feature is not installed by default. However, you can install it by downloading and installing Windows Management Framework (WMF) 3.0, which includes PowerShell 2.0, WinRM 2.0, and WMI 2.0. This section also explains how to start the PowerShell 2.0 Engine.</p>
|
96 |
-
<h4>How to install Windows Management Framework 3.0</h4>
|
97 |
-
<ol>
|
98 |
-
<li>Go to the <a href="">Windows Management Framework (WMF) 3.0 download page</a>.</li>
|
99 |
-
<li>Select the appropriate package for your operating system and language, and then click <strong>Download</strong>.</li>
|
100 |
-
<li>Run the downloaded file and follow the instructions to install WMF 3.0 on your computer. You might need to restart your computer after the installation is complete.</li>
|
101 |
-
</ol>
|
102 |
-
<h4>How to start the PowerShell 2.0 Engine</h4>
|
103 |
-
<p>The steps for starting the PowerShell 2.0 Engine are the same as for Windows Server 2012 R2 and Windows Server 2012. You need to use the <strong>-Version</strong> parameter of the <strong>powershell.exe</strong> or <strong>powershell_ise.exe</strong> command.</p>
|
104 |
-
<h2>How to Use PowerShell 2.0 Commands and Scripts</h2>
|
105 |
-
<p>Once you have installed and started the PowerShell 2.0 Engine, you can use it to run commands and scripts that are designed for PowerShell 2.0. Here are some tips and examples for using PowerShell 2.0 commands and scripts:</p>
|
106 |
-
<h3>How to start PowerShell with the PowerShell 2.0 Engine</h3>
|
107 |
-
<p>If you want to start a new PowerShell session with the PowerShell 2.0 Engine, you can use one of the following methods:</p>
|
108 |
-
<ul>
|
109 |
-
<li>In Windows Explorer, right-click a folder or drive, and then click <strong>Powershell (x86)</strong>. This will open a new PowerShell window with the PowerShell 2.0 Engine in that location.</li>
|
110 |
-
<li>In Windows Explorer, right-click a folder or drive, and then click <strong>Powershell ISE (x86)</strong>. This will open a new Windows PowerShell ISE window with the PowerShell 2.0 Engine in that location.</li>
|
111 |
-
<li>In Start Menu or Start Screen, type <strong>powershell.exe -Version 2</strong>, and then press <strong>Enter</strong>. This will open a new PowerShell window with the PowerShell 2.0 Engine.</li>
|
112 |
-
<li>In Start Menu or Start Screen, type <strong>powershell_ise.exe -Version 2</strong>, and then press <strong>Enter</strong>. This will open a new Windows PowerShell ISE window with the PowerShell 2.0 Engine.</li>
|
113 |
-
<li>In Command Prompt, type <strong>powershell.exe -Version 2</strong>, and then press <strong>Enter</strong>. This will start a new PowerShell session with the PowerShell 2.0 Engine within the Command Prompt window.</li>
|
114 |
-
<li>In Command Prompt, type <strong>powershell_ise.exe -Version 2</strong>, and then press <strong>Enter</strong>. This will start a new Windows PowerShell ISE session with the PowerShell 2.0 Engine within the Command Prompt window.</li>
|
115 |
-
</ul>
|
116 |
-
<h3>How to run PowerShell 2.0 commands and scripts</h3>
|
117 |
-
<p>If you want to run a single command or a script file that is compatible with PowerShell 2.0, you can use one of the following methods:</p>
|
118 |
-
<ul>
|
119 |
-
<li>In a PowerShell window or session with the PowerShell 2.0 Engine, type the command or the path of the script file, and then press <strong>Enter</strong>. For example, you can type <code>Get-Process</code> to get a list of processes running on your computer, or type <code>C:\Scripts\MyScript.ps1</code> to run a script file named MyScript.ps1 in the C:\Scripts folder.</li>
|
120 |
-
<li>In a Windows PowerShell ISE window or session with the PowerShell 2.0 Engine, type the command or the path of the script file in the Script Pane, and then click <strong>Run Script</strong> or press <strong>F5</strong>. For example, you can type <code>Get-Process</code> in the Script Pane, and then click <strong>Run Script</strong> to get a list of processes running on your computer, or type <code>C:\Scripts\MyScript.ps1</code> in the Script Pane, and then click <strong>Run Script</strong> to run a script file named MyScript.ps1 in the C:\Scripts folder.</li>
|
121 |
-
<li>In Command Prompt, type <strong>powershell.exe -Version 2 -Command "<command>"</strong>, where <command> is the command or the path of the script file that you want to run, and then press <strong>Enter</strong>. For example, you can type <code>powershell.exe -Version 2 -Command "Get-Process"</code> to get a list of processes running on your computer, or type <code>powershell.exe -Version 2 -Command "C:\Scripts\MyScript.ps1"</code> to run a script file named MyScript.ps1 in the C:\Scripts folder.</li>
|
122 |
-
<li>In Command Prompt, type <strong>powershell_ise.exe -Version 2 -File "<file>"</strong>, where <file> is the path of the script file that you want to run, and then press <strong>Enter</strong>. For example, you can type <code>powershell_ise.exe -Version 2 -File "C:\Scripts\MyScript.ps1"</code> to run a script file named MyScript.ps1 in the C:\Scripts folder.</li>
|
123 |
-
</ul>
|
124 |
-
<h3>How to start a remote session or a background job with the PowerShell 2.0 Engine</h3>
|
125 |
-
<p>If you want to start a remote session or a background job with another computer that has PowerShell 2.0 installed, you need to use the <strong>-ConfigurationName Microsoft.PowerShell.2.0</strong> parameter of the <strong>New-PSSession</strong>, <strong>New-PSSessionOption</strong>, or <strong>Start-Job</strong> cmdlet. For example, you can use the following command to start a remote session with another computer named Server01 using the PowerShell 2.0 Engine:</p>
|
126 |
-
<code>New-PSSession -ComputerName Server01 -ConfigurationName Microsoft.PowerShell.2.0</code>
|
127 |
-
<p>You can use the following command to start a background job on another computer named Server01 using the PowerShell 2.0 Engine:</p>
|
128 |
-
<code>Start-Job -ComputerName Server01 -ConfigurationName Microsoft.PowerShell.2.0 -ScriptBlock Get-Process</code>
|
129 |
-
<h2>Conclusion</h2>
|
130 |
-
<p>In this article, we have shown you how to download and install PowerShell 2.0 on different versions of Windows, how to use PowerShell 2.0 commands and scripts, and some tips and recommendations for using PowerShell 2.0. We hope that this article has been helpful and informative for you. Here are some FAQs that you might have about PowerShell 2.0:</p>
|
131 |
-
<h2>FAQs</h2>
|
132 |
-
<h3>What are the system requirements for PowerShell 2.0?</h3>
|
133 |
-
<p>The system requirements for PowerShell 2.0 depend on the version of Windows that you have. Here are the minimum system requirements for each version of Windows that supports PowerShell 2.0:</p>
|
134 |
-
<table>
|
135 |
-
<tr>
|
136 |
-
<th>Windows Version</th>
|
137 |
-
<th>Minimum System Requirements</th>
|
138 |
-
</tr>
|
139 |
-
<tr>
|
140 |
-
<td>Windows 8.1 and Windows 8</td>
|
141 |
-
<td>1 GHz processor, 1 GB RAM, 16 GB available disk space, DirectX 9 graphics device with WDDM 1.0 or higher driver</td>
|
142 |
-
</tr>
|
143 |
-
<tr>
|
144 |
-
<td>Windows Server 2012 R2 and Windows Server 2012</td>
|
145 |
-
<td>1.4 GHz processor, 512 MB RAM, 32 GB available disk space</td>
|
146 |
-
</tr>
|
147 |
-
<tr>
|
148 |
-
<td>Windows Server 2008 R2 and Windows Vista</td>
|
149 |
-
<td>1 GHz processor, 512 MB RAM, 15 GB available disk space, Super VGA (800 x 600) or higher-resolution monitor</td>
|
150 |
-
</tr>
|
151 |
-
<tr>
|
152 |
-
<td>Windows Server 2003 and Windows XP</td>
|
153 |
-
<td>233 MHz processor, 64 MB RAM, 1.5 GB available disk space, Super VGA (800 x 600) or higher-resolution monitor</td>
|
154 |
-
</tr>
|
155 |
-
</table>
|
156 |
-
<h3>Is PowerShell 2.0 compatible with newer versions of PowerShell?</h3>
|
157 |
-
<p>PowerShell 2.0 is generally compatible with newer versions of PowerShell, such as PowerShell 3.0, PowerShell 4.0, PowerShell 5.0, PowerShell 5.1, and PowerShell Core. However, there might be some differences or limitations in the functionality, syntax, or behavior of some commands or features between different versions of PowerShell. For example, some cmdlets or parameters that are available in newer versions of PowerShell might not be available or work differently in PowerShell 2.0. Therefore, it is recommended that you test your commands or scripts before running them on different versions of PowerShell to ensure that they work as expected.</p>
|
158 |
-
<h3>Is PowerShell 2.0 deprecated or insecure?</h3>
|
159 |
-
<p>PowerShell 2.0 is not deprecated or insecure by itself, but it might be affected by the deprecation or security status of the underlying .NET Framework version that it uses. For example, .NET Framework 3.5, which is required by PowerShell 2.0 on Windows 8.1 and Windows Server 2012, is no longer supported by Microsoft as of January 14, 2020. This means that it will not receive any security updates or patches from Microsoft, which might expose your system to potential vulnerabilities or risks. Therefore, it is recommended that you upgrade to a newer version of PowerShell and .NET Framework if possible, or apply the latest security updates and best practices for your system if you need to use PowerShell 2.0.</p>
|
160 |
-
<h3>Where can I find more information or help about PowerShell 2.0?</h3>
|
161 |
-
<p>If you want to learn more about PowerShell 2.0, you can refer to the following resources:</p>
|
162 |
-
<ul>
|
163 |
-
<li>The <a href="">PowerShell 2.0 documentation</a>, which provides a comprehensive guide to the features, syntax, and usage of PowerShell 2.0.</li>
|
164 |
-
<li>The <a href="">PowerShell 2.0 blog</a>, which provides news, updates, tips, and examples for using PowerShell 2.0.</li>
|
165 |
-
<li>The <a href="">PowerShell 2.0 forum</a>, which provides a platform for asking questions, sharing solutions, and getting help from other PowerShell users and experts.</li>
|
166 |
-
<li>The <a href="">PowerShell Gallery</a>, which provides a repository of PowerShell modules, scripts, and resources that you can download and use with PowerShell 2.0.</li>
|
167 |
-
</ul>
|
168 |
-
<h3>How can I uninstall or disable PowerShell 2.0?</h3>
|
169 |
-
<p>If you want to uninstall or disable PowerShell 2.0, you can use one of the following methods:</p>
|
170 |
-
<ul>
|
171 |
-
<li>On Windows 8.1 and Windows Server 2012 R2, you can turn off the PowerShell 2.0 Engine feature by following the steps in the previous section.</li>
|
172 |
-
<li>On Windows Server 2012 and Windows Server 2008 R2, you can remove the PowerShell 2.0 Engine feature by using the Server Manager or the Windows PowerShell cmdlets as described in the previous section.</li>
|
173 |
-
<li>On Windows Vista, Windows Server 2003, and Windows XP, you can uninstall Windows Management Framework 3.0 by using the Add or Remove Programs feature in Control Panel.</li>
|
174 |
-
</ul></p> 401be4b1e0<br />
|
175 |
-
<br />
|
176 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1phancelerku/anime-remove-background/Download Urdu Subtitles for Game of Thrones Season 2 Episode 5 The Ghost of Harrenhal.md
DELETED
@@ -1,201 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>How to Watch Game of Thrones Season 2 Episode 5 with Urdu Subtitles</h1>
|
3 |
-
<p>Game of Thrones is one of the most popular and acclaimed TV shows in history. Based on the fantasy novels by George R.R. Martin, it tells the story of a medieval world where several noble families vie for control over the Iron Throne, while an ancient threat looms beyond a massive wall in the north. The show is known for its complex characters, intricate plots, stunning visuals, and shocking twists.</p>
|
4 |
-
<h2>game of thrones season 2 episode 5 urdu subtitles download</h2><br /><p><b><b>Download Zip</b> ::: <a href="https://jinyurl.com/2uNKWZ">https://jinyurl.com/2uNKWZ</a></b></p><br /><br />
|
5 |
-
<p>Season 2 Episode 5, titled "The Ghost of Harrenhal", is one of the most pivotal episodes in the series. It features several major events that change the course of the war for the throne, as well as some intriguing developments in other parts of the world. In this article, we will give you a brief recap of what happens in this episode, and then show you how to watch it with Urdu subtitles.</p>
|
6 |
-
<p>Why would you want to watch Game of Thrones with Urdu subtitles? Well, there are several reasons. Maybe you are a fan of Urdu language and culture, and you want to enjoy the show in a different way. Maybe you are learning Urdu, and you want to improve your skills by watching a high-quality show. Maybe you have trouble understanding some accents or dialogues in English, and you want to make sure you don't miss anything important. Whatever your reason is , we have got you covered. In this article, we will tell you how to download Urdu subtitles for Game of Thrones Season 2 Episode 5, and how to watch it online or offline with the subtitles. But first, let's recap what happens in this episode.</p>
|
7 |
-
<h2>The Ghost of Harrenhal Recap</h2>
|
8 |
-
<p>"The Ghost of Harrenhal" is the fifth episode of the second season of Game of Thrones. It aired on April 29, 2012, and was written by David Benioff and D.B. Weiss, and directed by David Petrarca. The episode has a runtime of 55 minutes, and has a rating of 8.8 out of 10 on IMDb. Here are the main events that take place in this episode:</p>
|
9 |
-
<p>game of thrones s02e05 urdu subs download<br />
|
10 |
-
got season 2 episode 5 urdu subtitles free<br />
|
11 |
-
watch game of thrones season 2 episode 5 with urdu subtitles<br />
|
12 |
-
game of thrones season 2 episode 5 urdu srt download<br />
|
13 |
-
download game of thrones season 2 episode 5 in urdu<br />
|
14 |
-
game of thrones season 2 episode 5 urdu dubbed download<br />
|
15 |
-
game of thrones season 2 episode 5 online urdu subtitles<br />
|
16 |
-
game of thrones season 2 episode 5 urdu translation download<br />
|
17 |
-
game of thrones season 2 episode 5 subtitles in urdu<br />
|
18 |
-
game of thrones season 2 episode 5 urdu subscene download<br />
|
19 |
-
game of thrones season 2 episode 5 urdu language download<br />
|
20 |
-
game of thrones season 2 episode 5 full urdu subtitles<br />
|
21 |
-
how to download game of thrones season 2 episode 5 urdu subtitles<br />
|
22 |
-
game of thrones season 2 episode 5 english to urdu subtitles<br />
|
23 |
-
game of thrones season 2 episode 5 urdu version download<br />
|
24 |
-
game of thrones season 2 episode 5 with urdu subs<br />
|
25 |
-
game of thrones season 2 episode 5 urdu subtitle file download<br />
|
26 |
-
game of thrones season 2 episode 5 hd urdu subtitles<br />
|
27 |
-
game of thrones season 2 episode 5 best urdu subtitles<br />
|
28 |
-
game of thrones season 2 episode 5 easy urdu subtitles download<br />
|
29 |
-
game of thrones season two episode five urdu subtitles download<br />
|
30 |
-
where to download game of thrones season 2 episode 5 urdu subtitles<br />
|
31 |
-
game of thrones season second episode fifth urdu subtitles download<br />
|
32 |
-
game of thrones season ii episode v urdu subtitles download<br />
|
33 |
-
game of thrones the ghost of harrenhal urdu subtitles download<br />
|
34 |
-
download got s02e05 with urdu subtitles<br />
|
35 |
-
got the ghost of harrenhal urdu subs download<br />
|
36 |
-
watch got s02e05 online with urdu subtitles<br />
|
37 |
-
got s02e05 urdu srt file download<br />
|
38 |
-
got s02e05 in urdu language download<br />
|
39 |
-
got s02e05 urdu dubbed version download<br />
|
40 |
-
got s02e05 online with urdu translation<br />
|
41 |
-
got s02e05 subtitles in urdu language<br />
|
42 |
-
got s02e05 subscene urdu subtitle download<br />
|
43 |
-
got s02e05 full episode with urdu subs<br />
|
44 |
-
how to get got s02e05 with urdu subtitles<br />
|
45 |
-
got s02e05 english to urdu subtitle conversion<br />
|
46 |
-
got s02e05 hd quality with urdu subs<br />
|
47 |
-
got s02e05 best quality with urdu subs<br />
|
48 |
-
got s02e05 easy to download with urdu subs<br />
|
49 |
-
watch the ghost of harrenhal with urdu subtitles online<br />
|
50 |
-
the ghost of harrenhal subscene in urdu language <br />
|
51 |
-
the ghost of harrenhal full video with urdu subs <br />
|
52 |
-
the ghost of harrenhal english to urdu subtitle translation <br />
|
53 |
-
the ghost of harrenhal hd video with urdu subs <br />
|
54 |
-
the ghost of harrenhal best video with urdu subs <br />
|
55 |
-
the ghost of harrenhal easy video with urdu subs</p>
|
56 |
-
<h3>In the Stormlands</h3>
|
57 |
-
<p>The episode begins with a shocking scene: the assassination of Renly Baratheon, one of the claimants to the Iron Throne, by a shadowy figure that resembles his brother Stannis. The shadow is actually a creature conjured by Melisandre, a red priestess who serves Stannis and believes him to be the chosen one of her god. The murder is witnessed by Catelyn Stark, the widow of Ned Stark who was executed by King Joffrey, and Brienne of Tarth, a female knight who swore loyalty to Renly. They are accused of the crime by Renly's guards, but they manage to escape with the help of Loras Tyrell, Renly's lover and ally.</p>
|
58 |
-
<p>With Renly dead, most of his bannermen switch their allegiance to Stannis, who now has the largest army in Westeros. However, some of them remain loyal to the Tyrells, who are not willing to bend the knee to Stannis. Stannis offers to make Loras his heir if he joins him, but Loras refuses. He also rejects Catelyn's plea to join forces with Robb Stark, her son and the King in the North, who is fighting against Joffrey. Stannis then prepares to march on King's Landing, the capital of the Seven Kingdoms, where Joffrey resides.</p>
|
59 |
-
<p>Brienne and Catelyn decide to leave the Stormlands and head north. Brienne swears an oath to serve Catelyn and protect her. She also vows to avenge Renly's death by killing Stannis.</p>
|
60 |
-
<h3>In King's Landing</h3>
|
61 |
-
<p>In the capital, Tyrion Lannister, the witty and clever brother of Cersei Lannister, Joffrey's mother and regent, is trying to keep the city safe and stable as the Hand of the King. He discovers that Cersei has ordered the alchemists to produce large quantities of wildfire, a highly flammable and explosive substance that can burn anything. Cersei plans to use it as a weapon against Stannis' fleet when he attacks the city. Tyrion is alarmed by this idea, as he knows that wildfire is very dangerous and unpredictable. He decides to take control of the wildfire production and distribution, and tells Cersei that he will use it in a smarter way.</p>
|
62 |
-
<p>Tyrion also has to deal with the growing unrest and discontent among the people of King's Landing, who are suffering from hunger, poverty, and fear. He tries to appease them by sending Princess Myrcella Baratheon, Joffrey's younger sister, to Dorne, a southern kingdom that is allied with the Lannisters. He hopes that this will secure their friendship and prevent them from joining Stannis or Robb. He also hopes that Myrcella will be safer and happier in Dorne than in King's Landing.</p>
|
63 |
-
<p>However, his plan backfires when he escorts Myrcella to the ship that will take her to Dorne. The people of King's Landing riot and attack him and his entourage, throwing stones and insults at them. They also target Joffrey, who responds by ordering his guards to kill them all. A bloody chaos ensues, in which several people are killed or injured, including some of Tyrion's allies. Tyrion manages to survive and reach the safety of the Red Keep, the royal castle. He confronts Joffrey for his cruelty and stupidity, and slaps him in front of everyone.</p>
|
64 |
-
<h3>In Qarth</h3>
|
65 |
-
<p>Meanwhile, across the Narrow Sea in Essos, Daenerys Targaryen, the last surviving member of the Targaryen dynasty that ruled Westeros before Robert Baratheon overthrew them, is trying to find allies and resources for her quest to reclaim the Iron Throne. She has three young dragons, the only ones in existence, but they are still too small and weak to be used in battle. She also has a small band of loyal followers, including Jorah Mormont, a former knight who serves as her adviser and protector, and her bloodriders, a group of Dothraki warriors who swore to follow her after the death of her husband Khal Drogo.</p>
|
66 |
-
<p>Daenerys and her followers have been welcomed in Qarth, a wealthy and exotic city in the east, by Xaro Xhoan Daxos, a powerful merchant and a member of the Thirteen, the rulers of Qarth. Xaro offers Daenerys his hospitality and his friendship, but he also has ulterior motives. He proposes to marry Daenerys and give her half of his wealth, in exchange for one of her dragons. Daenerys refuses, as she considers her dragons to be her children and her only hope.</p>
|
67 |
-
<p>Daenerys also meets two mysterious characters in Qarth: Quaithe, a masked woman who claims to be a shadowbinder from Asshai, a dark and mysterious land in the far east; and Pyat Pree, a bald and blue-lipped warlock who invites Daenerys to visit the House of the Undying, the headquarters of his order. Quaithe warns Daenerys to beware of those who seek to use or harm her, and tells her that she must go to Asshai to learn the truth about her destiny. Pyat Pree promises Daenerys that she will see wonders and visions in the House of the Undying, and that he has something that belongs to her.</p>
|
68 |
-
<p>At the end of the episode, Daenerys discovers that Pyat Pree was telling the truth: he has stolen her dragons and taken them to the House of the Undying. He lured them away from their cage with a decoy, and killed most of Daenerys' guards in the process. Daenerys is furious and distraught, and vows to get her dragons back.</p>
|
69 |
-
<h3>Beyond the Wall</h3>
|
70 |
-
<p>Finally, in the frozen lands beyond the Wall, a massive barrier of ice that separates Westeros from the wild lands in the north, Jon Snow, the bastard son of Ned Stark who joined the Night's Watch, a sworn brotherhood that guards the Wall and protects the realm from the dangers beyond, is on a dangerous mission. He is part of a small group of rangers led by Qhorin Halfhand, a legendary warrior who is respected and feared by both his allies and enemies. Their goal is to find and kill Mance Rayder, a former member of the Night's Watch who deserted and became the King-Beyond-the-Wall, uniting the wildlings under his command.</p>
|
71 |
-
<p>On their way, they encounter a group of wildlings led by Ygritte, a fiery-haired woman who catches Jon's eye. They manage to kill or capture most of them, except for Ygritte, who is taken prisoner by Jon. Qhorin orders Jon to execute her, but Jon hesitates. He does not want to kill an unarmed woman, especially one that he finds attractive. He tries to do it anyway, but Ygritte escapes. Jon chases her through the snow, but loses sight of his comrades. He catches up with Ygritte, but she tricks him into falling into a trap. She then taunts him for being a virgin and a crow (a derogatory term for members of the Night's Watch), and tells him that he knows nothing about the world.</p>
|
72 |
-
<p>Meanwhile, in Winterfell, the ancestral home of the Starks in the north, Bran Stark, Ned's youngest son who was crippled after being pushed from a tower by Jaime Lannister, Cersei's brother and lover, is having strange dreams. He dreams that he is his direwolf Summer, running through the woods and hunting. He also dreams that he meets Jojen Reed, a boy who claims to have similar dreams and abilities. Jojen tells Bran that he is a warg, someone who can enter the minds of animals and control them. He also tells him that he has "the sight", which allows him to see past and future events. He warns Bran that he is in danger, and that he must find "the three-eyed raven", a mysterious figure that appears in his dreams.</p>
|
73 |
-
<p>In Pyke, the seat of House Greyjoy on the Iron Islands, an archipelago off the west coast of Westeros, Theon Greyjoy, Ned's former ward who betrayed him and joined his father Balon Greyjoy in his rebellion against the Lannisters, is preparing to leave with his sister Yara Greyjoy and her fleet. He has been given the task of raiding the coast of the north, while Robb Stark is away fighting in the south. He hopes to prove himself to his father and his people, who have always looked down on him for being raised by the Starks. He also hopes to impress Yara, who is a skilled and respected captain and warrior, and who mocks him for being weak and foolish.</p>
|
74 |
-
<h2>How to Download Urdu Subtitles for Game of Thrones Season 2 Episode 5</h2>
|
75 |
-
<p>Now that you have a clear idea of what happens in "The Ghost of Harrenhal", you might be wondering how to watch it with Urdu subtitles. Subtitles are a great way to enhance your viewing experience, especially if you are not a native speaker of English, or if you want to learn a new language. Subtitles can help you improve your vocabulary, grammar, pronunciation, and comprehension skills, as well as expose you to different cultures and expressions. They can also help you enjoy the show more, as you won't miss any important details or dialogues that might be hard to catch or understand otherwise.</p>
|
76 |
-
<p>So, how can you get Urdu subtitles for Game of Thrones Season 2 Episode 5? Well, there are several sources that offer them, both free and paid. However, not all of them are reliable or accurate. Some of them might have poor quality, incorrect translations, missing or delayed lines, or even malware or viruses. Therefore, you need to be careful and choose the best source for your needs. Here are some of the factors that you should consider when looking for Urdu subtitles for Game of Thrones Season 2 Episode 5:</p>
|
77 |
-
- Quality: The subtitles should be clear, readable, and synchronized with the video and audio. They should also match the tone, style, and context of the show. - Accuracy: The subtitles should convey the meaning and intention of the original dialogue, without adding or omitting anything. They should also respect the grammar, spelling, and punctuation rules of Urdu. - Availability: The subtitles should be easy to find and download, without requiring any registration or payment. They should also be compatible with your device and media player. - Legality: The subtitles should be legal and authorized by the creators or owners of the show. They should not violate any copyright or intellectual property laws. <p>Based on these criteria, we have compiled a list of some of the best websites that offer Urdu subtitles for Game of Thrones Season 2 Episode 5. Here they are:</p>
|
78 |
-
<table>
|
79 |
-
<tr>
|
80 |
-
<th>Website</th>
|
81 |
-
<th>Quality</th>
|
82 |
-
<th>Accuracy</th>
|
83 |
-
<th>Availability</th>
|
84 |
-
<th>Legality</th>
|
85 |
-
</tr>
|
86 |
-
<tr>
|
87 |
-
<td>[isubdb.com]</td>
|
88 |
-
<td>High</td>
|
89 |
-
<td>High</td>
|
90 |
-
<td>Free and easy</td>
|
91 |
-
<td>Legal</td>
|
92 |
-
</tr>
|
93 |
-
<tr>
|
94 |
-
<td>[subscene.com]</td>
|
95 |
-
<td>High</td>
|
96 |
-
<td>High</td>
|
97 |
-
<td>Free and easy</td>
|
98 |
-
<td>Legal</td>
|
99 |
-
</tr>
|
100 |
-
<tr>
|
101 |
-
<td>[opensubtitles.org]</td>
|
102 |
-
<td>Medium</td>
|
103 |
-
<td>Medium</td>
|
104 |
-
<td>Free but requires registration</td>
|
105 |
-
<td>Legal</td>
|
106 |
-
</tr>
|
107 |
-
<tr>
|
108 |
-
<td>[tvsubtitles.net]</td>
|
109 |
-
<td>Low</td>
|
110 |
-
<td>Low</td>
|
111 |
-
<td>Free but slow and unreliable</td>
|
112 |
-
<td>Illegal</td>
|
113 |
-
</tr>
|
114 |
-
</table>
|
115 |
-
<p>As you can see from the table above, our recommendation is to use [isubdb.com] as your source of Urdu subtitles for Game of Thrones Season 2 Episode 5. This website has high-quality and accurate subtitles that are free and easy to download. It also has a large collection of subtitles for other episodes and seasons of Game of Thrones, as well as other shows and movies. It is also legal and safe to use.</p>
|
116 |
-
<p>To download Urdu subtitles from [isubdb.com], all you have to do is follow these simple steps:</p>
|
117 |
-
- Go to [isubdb.com] on your browser - Type "Game of Thrones" in the search box - Select "Game of Thrones - Season 2" from the results - Scroll down to "Episode 5 - The Ghost of Harrenhal" - Click on "Urdu" under "Subtitles" - Click on "Download" next to the subtitle file that you want - Save the file on your device - You have successfully downloaded the Urdu subtitles for Game of Thrones Season 2 Episode 5. Now, you can watch the episode with the subtitles on your device. But how do you do that? There are two options: online streaming or offline downloading. Let's see what they are and how they work. <h2>How to Watch Game of Thrones Season 2 Episode 5 with Urdu Subtitles Online or Offline</h2>
|
118 |
-
<p>Online streaming is the option of watching the episode on a platform that allows you to stream it over the internet, without having to download it on your device. This option is convenient and fast, as you can watch the episode anytime and anywhere, as long as you have a stable internet connection. However, this option also has some drawbacks, such as requiring a subscription or payment, consuming a lot of data, or being subject to geo-restrictions or censorship.</p>
|
119 |
-
<p>Offline downloading is the option of downloading the episode on your device, and then watching it with a media player that supports subtitles. This option is more flexible and reliable, as you can watch the episode offline, without worrying about internet issues or interruptions. However, this option also has some challenges, such as taking up a lot of space, exposing you to malware or viruses, or violating legal or ethical rules.</p>
|
120 |
-
<p>So, which option should you choose? Well, that depends on your preferences and circumstances. To help you decide, we have compared some of the best platforms and methods for online streaming and offline downloading of Game of Thrones Season 2 Episode 5 with Urdu subtitles. Here they are:</p>
|
121 |
-
<h3>Online Streaming Options</h3>
|
122 |
-
<p>There are many platforms that allow you to stream Game of Thrones online, with or without subtitles. However, not all of them are available or accessible in every country or region. Therefore, you need to check the availability and compatibility of the platform before choosing it. Here are some of the most popular and reliable platforms that offer online streaming of Game of Thrones Season 2 Episode 5 with Urdu subtitles:</p>
|
123 |
-
<table>
|
124 |
-
<tr>
|
125 |
-
<th>Platform</th>
|
126 |
-
<th>Features</th>
|
127 |
-
<th>Price</th>
|
128 |
-
<th>Compatibility</th>
|
129 |
-
</tr>
|
130 |
-
<tr>
|
131 |
-
<td>HBO Max</td>
|
132 |
-
<td>- The official and legal platform for streaming Game of Thrones - High-quality video and audio - Supports multiple languages and subtitles - Offers other HBO shows and movies - Allows offline downloading on mobile devices</td>
|
133 |
-
<td>$14.99 per month</td>
|
134 |
-
<td>Available in the US and some Latin American countries Compatible with most devices and browsers</td>
|
135 |
-
</tr>
|
136 |
-
<tr>
|
137 |
-
<td>Netflix</td>
|
138 |
-
<td>- The most popular and widely used streaming platform - High-quality video and audio - Supports multiple languages and subtitles - Offers a large variety of shows and movies - Allows offline downloading on mobile devices</td>
|
139 |
-
<td>$8.99 to $17.99 per month depending on the plan</td>
|
140 |
-
<td>Available in most countries except China, Syria, North Korea, and Crimea Compatible with most devices and browsers</td>
|
141 |
-
</tr>
|
142 |
-
<tr>
|
143 |
-
<td>Amazon Prime Video</td>
|
144 |
-
<td>- The streaming platform of Amazon - High-quality video and audio - Supports multiple languages and subtitles - Offers other Amazon shows and movies - Allows offline downloading on mobile devices</td>
|
145 |
-
<td>$8.99 per month or $119 per year for Prime membership</td>
|
146 |
-
<td>Available in most countries except China, Iran, North Korea, Syria, and Crimea Compatible with most devices and browsers</td>
|
147 |
-
</tr>
|
148 |
-
</table>
|
149 |
-
<p>As you can see from the table above, our recommendation is to use HBO Max as your platform for online streaming of Game of Thrones Season 2 Episode 5 with Urdu subtitles. This is because HBO Max is the official and legal platform for streaming Game of Thrones, and it offers high-quality video and audio, as well as multiple languages and subtitles. It also offers other HBO shows and movies that you might enjoy, such as Westworld, The Sopranos, The Wire, etc. It also allows offline downloading on mobile devices, which is convenient if you want to watch the episode later.</p>
|
150 |
-
<p>To stream Game of Thrones Season 2 Episode 5 with Urdu subtitles on HBO Max, all you have to do is follow these simple steps:</p>
|
151 |
-
- Go to [hbomax.com] on your browser - Sign up for an account or log in if you already have one - Choose your plan and payment method - Search for "Game of Thrones" in the search box - Select "Game of Thrones - Season 2" from the results - Scroll down to "Episode 5 - The Ghost of Harrenhal" - Click on "Play" - Click on the settings icon at the bottom right corner of the screen - Click on "Subtitles" - Click on "Urdu" - Enjoy watching the episode with Urdu subtitles. <h3>Offline Downloading Options</h3>
|
152 |
-
<p>If you prefer to download the episode on your device and watch it offline, you have some other options as well. However, you need to be aware of the risks and challenges that come with this option, such as malware, viruses, legal issues, or ethical dilemmas. Therefore, you need to be careful and responsible when choosing this option. Here are some of the most common and effective methods for offline downloading of Game of Thrones Season 2 Episode 5 with Urdu subtitles:</p>
|
153 |
-
<table>
|
154 |
-
<tr>
|
155 |
-
<th>Method</th>
|
156 |
-
<th>Speed</th>
|
157 |
-
<th>Security</th>
|
158 |
-
<th>Legality</th>
|
159 |
-
</tr>
|
160 |
-
<tr>
|
161 |
-
<td>Torrenting</td>
|
162 |
-
<td>Fast</td>
|
163 |
-
<td>Risky</td>
|
164 |
-
<td>Illegal</td>
|
165 |
-
</tr>
|
166 |
-
<tr>
|
167 |
-
<td>Direct Downloading</td>
|
168 |
-
<td>Slow</td>
|
169 |
-
<td>Safer</td>
|
170 |
-
<td>Illegal</td>
|
171 |
-
</tr>
|
172 |
-
<tr>
|
173 |
-
<td>DVD/Blu-ray Ripping</td>
|
174 |
-
<td>Medium</td>
|
175 |
-
<td>Safe</td>
|
176 |
-
<td>Legal</td>
|
177 |
-
</tr>
|
178 |
-
</table>
|
179 |
-
<p>As you can see from the table above, our recommendation is to use DVD/Blu-ray ripping as your method for offline downloading of Game of Thrones Season 2 Episode 5 with Urdu subtitles. This is because DVD/Blu-ray ripping is the only legal and safe method among the three, as it does not involve downloading or sharing pirated content. It also offers decent speed and quality, as well as the option to choose your preferred language and subtitles. However, this method also requires that you own or buy a physical copy of the episode on DVD or Blu-ray, which might be expensive or hard to find.</p>
|
180 |
-
<p>To rip Game of Thrones Season 2 Episode 5 with Urdu subtitles from DVD or Blu-ray, all you have to do is follow these simple steps:</p>
|
181 |
-
- Insert the DVD or Blu-ray disc into your computer's drive - Download and install a DVD/Blu-ray ripping software, such as [HandBrake] or [MakeMKV] - Open the software and select the disc as the source - Choose the output format and settings that suit your device and preferences - Select "Urdu" as the subtitle language - Click on "Start" or "Rip" to begin the process - Wait for the process to finish and save the file on your device - You have successfully ripped Game of Thrones Season 2 Episode 5 with Urdu subtitles from DVD or Blu-ray. Now, you can watch the episode with a media player that supports subtitles, such as [VLC] or [KMPlayer]. <h2>Conclusion</h2>
|
182 |
-
<p>In this article, we have shown you how to watch Game of Thrones Season 2 Episode 5 with Urdu subtitles. We have given you a brief recap of what happens in this episode, and then explained how to download Urdu subtitles from various sources. We have also compared some of the best platforms and methods for online streaming and offline downloading of the episode with Urdu subtitles. We hope that you have found this article helpful and informative, and that you will enjoy watching this episode with Urdu subtitles.</p>
|
183 |
-
<p>If you are a fan of Game of Thrones, you might also want to check out our other articles on how to watch other episodes and seasons of the show with Urdu subtitles. You might also want to share your feedback and opinions on this episode and the show in general with us and other readers. You can do so by leaving a comment below or by contacting us through our website or social media channels.</p>
|
184 |
-
<p>Thank you for reading this article, and happy watching!</p>
|
185 |
-
<h2>Frequently Asked Questions (FAQs)</h2>
|
186 |
-
<p>Here are some of the most common questions that people ask about watching Game of Thrones Season 2 Episode 5 with Urdu subtitles:</p>
|
187 |
-
<h3>Q: Where can I watch Game of Thrones Season 2 Episode 5 with Urdu subtitles for free?</h3>
|
188 |
-
<p>A: There are some websites that offer free streaming or downloading of Game of Thrones Season 2 Episode 5 with Urdu subtitles, such as [isubdb.com], [subscene.com], or [opensubtitles.org]. However, these websites might not be legal or safe to use, as they might contain pirated content or malware. Therefore, we recommend that you use a paid or official platform for streaming or downloading the episode, such as HBO Max, Netflix, or Amazon Prime Video.</p>
|
189 |
-
<h3>Q: How can I watch Game of Thrones Season 2 Episode 5 with Urdu subtitles on my TV?</h3>
|
190 |
-
<p>A: There are several ways to watch Game of Thrones Season 2 Episode 5 with Urdu subtitles on your TV. One way is to connect your computer or laptop to your TV using an HDMI cable or a wireless connection. Another way is to use a streaming device, such as a Roku, Chromecast, Apple TV, or Fire TV, that supports the platform that you are using to stream the episode, such as HBO Max, Netflix, or Amazon Prime Video. A third way is to use a smart TV that has the platform that you are using to stream the episode built-in or available as an app. In any case, you need to make sure that the platform that you are using supports Urdu subtitles, and that you enable them before or during watching the episode.</p>
|
191 |
-
<h3>Q: How can I watch Game of Thrones Season 2 Episode 5 with Urdu subtitles on my phone or tablet?</h3>
|
192 |
-
<p>A: There are also several ways to watch Game of Thrones Season 2 Episode 5 with Urdu subtitles on your phone or tablet. One way is to use the browser on your device to access the website that offers online streaming or downloading of the episode with Urdu subtitles, such as [isubdb.com], [subscene.com], or [opensubtitles.org]. However, this way might not be very convenient or comfortable, as the website might not be optimized for mobile devices, and the subtitles might not be very clear or readable. Another way is to use the app of the platform that you are using to stream or download the episode, such as HBO Max, Netflix, or Amazon Prime Video. This way is more convenient and comfortable, as the app is designed for mobile devices, and the subtitles are more clear and readable. However, this way requires that you have a subscription or payment for the platform, and that you have enough space and data on your device. A third way is to download the episode and the subtitles on your computer or laptop, and then transfer them to your device using a USB cable or a wireless connection. This way is more flexible and reliable, as you can watch the episode offline, without worrying about internet issues or interruptions. However, this way also requires that you have enough space and data on your device, and that you use a media player that supports subtitles, such as [VLC] or [KMPlayer].</p>
|
193 |
-
<h3>Q: How can I watch Game of Thrones Season 2 Episode 5 with Urdu subtitles in HD quality?</h3>
|
194 |
-
<p>A: To watch Game of Thrones Season 2 Episode 5 with Urdu subtitles in HD quality, you need to make sure that both the video and the subtitles are in HD quality. The video quality depends on the source and the platform that you are using to stream or download the episode. The subtitles quality depends on the source and the format that you are using to download or enable them. Generally speaking, the higher the quality of the video and the subtitles, the larger the file size and the more data they consume. Therefore, you need to balance between quality and speed when choosing your source and platform. For example, if you want to stream the episode in HD quality with Urdu subtitles online, you might want to use HBO Max, Netflix, or Amazon Prime Video, as they offer high-quality video and audio, as well as multiple languages and subtitles. However, if you want to download the episode in HD quality with Urdu subtitles offline, you might want to use torrenting or direct downloading from a reliable website, such as [isubdb.com], [subscene.com], or [opensubtitles.org], as they offer high-quality video and subtitles files.</p>
|
195 |
-
<h3>Q: How can I watch Game of Thrones Season 2 Episode 5 with Urdu subtitles with my friends?</h3>
|
196 |
-
<p>A: If you want to watch Game of Thrones Season 2 Episode 5 with Urdu subtitles with your friends, you have some options as well. One option is to watch it together in person, either at your place or at their place. You can use any of the methods or platforms that we have mentioned above to watch the episode with Urdu subtitles on your TV, computer, laptop, phone, or tablet. You can also use speakers or headphones to enhance the sound quality. Another option is to watch it together online, using a platform or an app that allows you to watch videos with your friends remotely, such as [Watch2Gether], [Netflix Party], or [Scener]. These platforms or apps let you create a private room where you can invite your friends and watch the episode with Urdu subtitles synchronously. You can also chat and comment with your friends while watching the episode. However, these platforms or apps might require that you and your friends have a subscription or payment for the platform that you are using to stream the episode, such as HBO Max, Netflix, or Amazon Prime Video.</p>
|
197 |
-
<p>Whichever option you choose, watching Game of Thrones Season 2 Episode 5 with Urdu subtitles with your friends can be a fun and enjoyable experience. You can share your thoughts and feelings about the episode, discuss the characters and the plot, and have a good time together.</p>
|
198 |
-
<h2></h2>
|
199 |
-
<p>This is the end of the article. I hope that you have learned something new and useful from this article, and that you have enjoyed reading it. If you have any questions, comments, or suggestions about this article or the topic of watching Game of Thrones Season 2 Episode 5 with Urdu subtitles, please feel free to contact me through my website or social media channels. I would love to hear from you and help you with anything that you need. Thank you for your time and attention, and have a great day!</p> 197e85843d<br />
|
200 |
-
<br />
|
201 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1phancelerku/anime-remove-background/Drag Racing Streets Mod Apk A Physics-Based Racing Game with Unlimited Money and Customization.md
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Drag Racing: Streets Mod APK - Unlimited Money and Fun</h1>
|
3 |
-
<p>Do you love drag racing games? Do you want to experience the thrill of driving fast cars on realistic streets? Do you want to customize your own car and compete with other players online? If you answered yes to any of these questions, then you should try Drag Racing: Streets, a popular racing game for Android devices. And if you want to make the game even more fun and exciting, you should download Drag Racing: Streets Mod APK, a modified version of the game that gives you unlimited money, coins, levels, cars, and more. In this article, we will tell you everything you need to know about Drag Racing: Streets and its mod apk version.</p>
|
4 |
-
<h2>drag racing streets mod apk unlimited money 2.0 7</h2><br /><p><b><b>Download File</b> ————— <a href="https://jinyurl.com/2uNQV5">https://jinyurl.com/2uNQV5</a></b></p><br /><br />
|
5 |
-
<h2>What is Drag Racing: Streets?</h2>
|
6 |
-
<p>Drag Racing: Streets is a racing game developed by Square, a Russian studio that specializes in realistic car simulation games. The game lets you create your own car from scratch, choosing from hundreds of parts and options. You can also customize your car's appearance, performance, tuning, and upgrades. You can then take your car to the streets and race against real players from around the world in various modes and events. You can also build your own garage and collect different cars.</p>
|
7 |
-
<h3>Features of Drag Racing: Streets</h3>
|
8 |
-
<p>Drag Racing: Streets has many features that make it one of the best drag racing games on the market. Here are some of them:</p>
|
9 |
-
<h4>Customize your car</h4>
|
10 |
-
<p>You can create your own car from scratch, choosing from hundreds of parts and options. You can change the engine, transmission, suspension, brakes, tires, wheels, body kits, paint, stickers, and more. You can also adjust the settings of your car's performance, such as power, torque, weight distribution, gear ratios, boost pressure, nitrous oxide injection, etc. You can make your car look and perform exactly how you want it.</p>
|
11 |
-
<h4>Race against real players</h4>
|
12 |
-
<p>You can race against real players from around the world in various modes and events. You can join tournaments, championships, leagues, seasons, daily races, etc. You can also challenge your friends or random opponents in one-on-one duels. You can show off your skills and win prizes and rewards.</p>
|
13 |
-
<h4>Build your own garage</h4>
|
14 |
-
<p>You can build your own garage and collect different cars. You can buy new cars or win them in races or events. You can also sell or trade your cars with other players. You can have up to 16 cars in your garage at a time.</p>
|
15 |
-
<p>drag racing streets mod apk download latest version 2022<br />
|
16 |
-
drag racing streets unlimited money and gold mod apk<br />
|
17 |
-
drag racing streets hack mod apk free download<br />
|
18 |
-
drag racing streets mod apk android 1 com<br />
|
19 |
-
drag racing streets mod apk revdl com<br />
|
20 |
-
drag racing streets mod apk rexdl com<br />
|
21 |
-
drag racing streets mod apk offline<br />
|
22 |
-
drag racing streets mod apk no root<br />
|
23 |
-
drag racing streets mod apk obb<br />
|
24 |
-
drag racing streets mod apk data<br />
|
25 |
-
drag racing streets mod apk unlimited everything<br />
|
26 |
-
drag racing streets mod apk unlimited coins and gems<br />
|
27 |
-
drag racing streets mod apk unlimited nitro<br />
|
28 |
-
drag racing streets mod apk unlimited fuel<br />
|
29 |
-
drag racing streets mod apk unlimited cash<br />
|
30 |
-
drag racing streets mod apk all cars unlocked<br />
|
31 |
-
drag racing streets mod apk all parts unlocked<br />
|
32 |
-
drag racing streets mod apk full version<br />
|
33 |
-
drag racing streets mod apk premium<br />
|
34 |
-
drag racing streets mod apk pro<br />
|
35 |
-
drag racing streets mod apk vip<br />
|
36 |
-
drag racing streets mod apk mega<br />
|
37 |
-
drag racing streets mod apk god mode<br />
|
38 |
-
drag racing streets mod apk anti ban<br />
|
39 |
-
drag racing streets mod apk online<br />
|
40 |
-
drag racing streets physics engine mod apk<br />
|
41 |
-
drag racing streets car customization mod apk<br />
|
42 |
-
drag racing streets realistic graphics mod apk<br />
|
43 |
-
drag racing streets best cars mod apk<br />
|
44 |
-
drag racing streets best tunes mod apk<br />
|
45 |
-
drag racing streets cheats mod apk<br />
|
46 |
-
drag racing streets tips and tricks mod apk<br />
|
47 |
-
drag racing streets gameplay mod apk<br />
|
48 |
-
drag racing streets review mod apk<br />
|
49 |
-
drag racing streets update mod apk<br />
|
50 |
-
how to install drag racing streets mod apk<br />
|
51 |
-
how to play drag racing streets mod apk<br />
|
52 |
-
how to get drag racing streets mod apk<br />
|
53 |
-
how to download drag racing streets mod apk for android<br />
|
54 |
-
how to download drag racing streets mod apk for ios<br />
|
55 |
-
how to download drag racing streets mod apk for pc<br />
|
56 |
-
how to download drag racing streets mod apk for laptop<br />
|
57 |
-
how to download drag racing streets mod apk for windows 10<br />
|
58 |
-
how to download drag racing streets mod apk for macbook pro<br />
|
59 |
-
how to download drag racing streets mod apk for chromebook</p>
|
60 |
-
<h3>Why download Drag Racing: Streets Mod APK?</h3>
|
61 |
-
<p>Drag Racing: Streets is a fun and addictive game, but it can also be challenging and frustrating at times. You may need a lot of money and coins to buy new cars, parts, upgrades, etc. You may also need to unlock new levels and cars to access more features and modes. And you may face ads and pop-ups that interrupt your gameplay.</p>
|
62 |
-
<p>That's why you should download Drag Racing: Streets Mod APK, a modified version of the game that gives you unlimited money, coins, levels, cars, and more. With this mod apk version, you can enjoy the game without any limitations or restrictions. You can buy anything you want, unlock everything you need, and play without any ads or interruptions.</p>
|
63 |
-
<h4>Unlimited money and coins</h4>
|
64 |
-
<p>With Drag Racing: Streets Mod APK, you will get unlimited money and coins in your account. You can use them to buy new cars, parts, upgrades, etc. <h4>Unlocked levels and cars</h4>
|
65 |
-
<p>With Drag Racing: Streets Mod APK, you will get all the levels and cars unlocked in the game. You can access any mode or event you want, and choose any car you like. You can also try out different cars and see how they perform on the streets.</p>
|
66 |
-
<h4>Free and safe to use</h4>
|
67 |
-
<p>Drag Racing: Streets Mod APK is free and safe to use. You don't need to root your device or install any other apps to use it. You just need to download the mod apk file from a trusted source and install it on your device. You can also update the game regularly without losing your mod features.</p>
|
68 |
-
<h2>How to download and install Drag Racing: Streets Mod APK?</h2>
|
69 |
-
<p>If you want to download and install Drag Racing: Streets Mod APK, you need to follow these simple steps:</p>
|
70 |
-
<h3>Step 1: Download the mod apk file</h3>
|
71 |
-
<p>You can download the mod apk file from this link: <a href="">Drag Racing: Streets Mod APK Download</a>. The file size is about 300 MB, so make sure you have enough space on your device. You can also scan the file with an antivirus program before opening it.</p>
|
72 |
-
<h3>Step 2: Enable unknown sources</h3>
|
73 |
-
<p>Before you can install the mod apk file, you need to enable unknown sources on your device. This will allow you to install apps from sources other than the Google Play Store. To do this, go to Settings > Security > Unknown Sources and toggle it on.</p>
|
74 |
-
<h3>Step 3: Install the mod apk file</h3>
|
75 |
-
<p>After you have enabled unknown sources, you can install the mod apk file. To do this, locate the file in your downloads folder and tap on it. You will see a pop-up window asking for your permission to install the app. Tap on Install and wait for the installation process to finish.</p>
|
76 |
-
<h3>Step 4: Enjoy the game</h3>
|
77 |
-
<p>Once the installation is done, you can open the game and enjoy it. You will see that you have unlimited money, coins, levels, cars, and more. You can start playing the game and have fun.</p>
|
78 |
-
<h2>Conclusion</h2>
|
79 |
-
<p>Drag Racing: Streets is a great racing game that lets you create your own car and race against real players on realistic streets. It has many features that make it fun and addictive. However, if you want to make the game even more enjoyable, you should download Drag Racing: Streets Mod APK, a modified version of the game that gives you unlimited money, coins, levels, cars, and more. With this mod apk version, you can buy anything you want, unlock everything you need, and play without any ads or interruptions. You can also download and install the mod apk easily and safely by following our guide.</p>
|
80 |
-
<p>If you are a fan of drag racing games, you should not miss Drag Racing: Streets Mod APK. Download it now and experience the thrill of driving fast cars on realistic streets.</p>
|
81 |
-
<h2>FAQs</h2>
|
82 |
-
<p>Here are some frequently asked questions about Drag Racing: Streets Mod APK:</p>
|
83 |
-
<ul>
|
84 |
-
<li><b>Q: Is Drag Racing: Streets Mod APK legal?</b></li>
|
85 |
-
<li>A: Drag Racing: Streets Mod APK is not legal, as it violates the terms and conditions of the original game. However, it is unlikely that you will face any legal consequences for using it, as long as you use it for personal and non-commercial purposes.</li>
|
86 |
-
<li><b>Q: Is Drag Racing: Streets Mod APK safe?</b></li>
|
87 |
-
<li>A: Drag Racing: Streets Mod APK is safe to use, as long as you download it from a trusted source and scan it with an antivirus program before installing it. However, we cannot guarantee that it will not harm your device or data in any way, so use it at your own risk.</li>
|
88 |
-
<li><b>Q: Will Drag Racing: Streets Mod APK work on my device?</b></li>
|
89 |
-
<li>A: Drag Racing: Streets Mod APK should work on most Android devices that support the original game. However, some devices may not be compatible with the mod apk version or may experience some glitches or errors while running it.</li>
|
90 |
-
<li><b>Q: Can I play online with Drag Racing: Streets Mod APK?</b></li>
|
91 |
-
<li>A: Yes, you can play online with Drag Racing: Streets Mod APK, as it does not affect your connection or account. However, you may face some disadvantages or unfairness while playing with other players who are using the original game or a different mod apk version.</li>
|
92 |
-
<li><b>Q: Can I update Drag Racing: Streets Mod APK?</b></li>
|
93 |
-
<li>A: Yes, you can update Drag Racing: Streets A: Yes, you can update Drag Racing: Streets Mod APK whenever a new version of the game is released. You can download the latest mod apk file from the same source and install it over the existing one. You can also check for updates within the game itself. However, you may lose some of your mod features or data after updating, so make sure you back up your progress before doing so.</li>
|
94 |
-
</ul></p> 401be4b1e0<br />
|
95 |
-
<br />
|
96 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1phancelerku/anime-remove-background/Enjoy Action RPG and Free Shopping with Pixel Blade M VIP Mod APK.md
DELETED
@@ -1,117 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Pixel Blade M VIP Mod APK Free Shopping: A Review</h1>
|
3 |
-
<p>If you are looking for a fun and exciting game that combines pixel-style graphics and hack-and-slash action, then you should check out Pixel Blade M VIP. This is a cubic action RPG game that lets you play as the last pixel hero in PIXEL WORLD. You can collect various weapons by hunting monsters in the dungeon and save the world from evil forces. But what if you want to enjoy the game without spending real money or watching annoying ads? Well, there is a solution for that: Pixel Blade M VIP Mod APK Free Shopping. This is a modified version of the game that gives you unlimited money and gems, free shopping for weapons and items, no ads, and no root required. In this article, we will review this mod apk and tell you why you should try it out.</p>
|
4 |
-
<h2>pixel blade m vip mod apk free shopping</h2><br /><p><b><b>Download File</b> >>> <a href="https://jinyurl.com/2uNKm6">https://jinyurl.com/2uNKm6</a></b></p><br /><br />
|
5 |
-
<h2>What is Pixel Blade M VIP?</h2>
|
6 |
-
<p>Pixel Blade M VIP is a 3D pixel fantasy hack-and-slash game developed by PixelStar Games. It is a sequel to the popular Pixel Blade game that has over 1 million downloads on Google Play. In this game, you can choose from different classes of pixel heroes, such as warrior, mage, archer, assassin, and more. You can also customize your hero's appearance, skills, and equipment. The game features various modes, such as story mode, boss mode, tower mode, raid mode, and PVP mode. You can explore different dungeons and fight against various monsters and bosses. You can also join a guild and cooperate with other players to defeat powerful enemies.</p>
|
7 |
-
<h3>Features of Pixel Blade M VIP</h3>
|
8 |
-
<p>Some of the features of Pixel Blade M VIP are:</p>
|
9 |
-
<ul>
|
10 |
-
<li>Pixel-style graphics 3D action RPG game</li>
|
11 |
-
<li>Various classes of pixel heroes with different skills and abilities</li>
|
12 |
-
<li>Over 100 kinds of weapons and items to collect and upgrade</li>
|
13 |
-
<li>Different modes to enjoy, such as story mode, boss mode, tower mode, raid mode, and PVP mode</li>
|
14 |
-
<li>Guild system to join forces with other players</li>
|
15 |
-
<li>Daily quests and achievements to complete</li>
|
16 |
-
<li>VIP benefits, such as extra gems, gold, inventory slots, etc.</li>
|
17 |
-
</ul>
|
18 |
-
<h3>How to download and install Pixel Blade M VIP Mod APK</h3>
|
19 |
-
<p>If you want to download and install Pixel Blade M VIP Mod APK Free Shopping, you need to follow these steps:</p>
|
20 |
-
<ol>
|
21 |
-
<li>Click on this link to download the mod apk file.</li>
|
22 |
-
<li>Allow unknown sources on your device by going to Settings > Security > Unknown Sources.</li>
|
23 |
-
<li>Locate the downloaded file in your file manager and tap on it to install it.</li>
|
24 |
-
<li>Launch the game and enjoy free shopping and unlimited money.</li>
|
25 |
-
</ol>
|
26 |
-
<h2>Why you should try Pixel Blade M VIP Mod APK Free Shopping</h2>
|
27 |
-
<p>There are many reasons why you should try Pixel Blade M VIP Mod APK Free Shopping. Here are some of them:</p>
|
28 |
-
<h3>Unlimited money and gems</h3>
|
29 |
-
<p>With this mod apk, you will get unlimited money and gems in your account. You can use them to buy any weapon or item you want without worrying about the cost. You can also upgrade your weapons and items to make them more powerful. This will help you progress faster in the game and defeat stronger enemies.</p>
|
30 |
-
<p>pixel blade m unlimited money and keys mod apk<br />
|
31 |
-
pixel blade m god mode and free shopping mod apk<br />
|
32 |
-
pixel blade m 3d rpg mod apk with vip features<br />
|
33 |
-
pixel blade m hack mod apk for free shopping and keys<br />
|
34 |
-
pixel blade m latest version mod apk with god mode<br />
|
35 |
-
pixel blade m vip mod apk download for android<br />
|
36 |
-
pixel blade m mod apk free shopping and unlimited keys<br />
|
37 |
-
pixel blade m 9.2.7 mod apk with god mode and vip<br />
|
38 |
-
pixel blade m role-playing game mod apk free shopping<br />
|
39 |
-
pixel blade m 3d graphics mod apk with unlimited money<br />
|
40 |
-
pixel blade m adventure game mod apk with god mode<br />
|
41 |
-
pixel blade m vip features mod apk free download<br />
|
42 |
-
pixel blade m free shopping and keys mod apk 9.2.7<br />
|
43 |
-
pixel blade m unlimited money and god mode mod apk<br />
|
44 |
-
pixel blade m 3d rpg hack mod apk with vip<br />
|
45 |
-
pixel blade m latest mod apk free shopping and keys<br />
|
46 |
-
pixel blade m 9.2.7 vip mod apk download for android<br />
|
47 |
-
pixel blade m role-playing game hack mod apk with god mode<br />
|
48 |
-
pixel blade m 3d graphics hack mod apk with unlimited money<br />
|
49 |
-
pixel blade m adventure game hack mod apk with vip features<br />
|
50 |
-
pixel blade m free download mod apk with free shopping and keys<br />
|
51 |
-
pixel blade m unlimited money and keys hack mod apk<br />
|
52 |
-
pixel blade m god mode and free shopping hack mod apk<br />
|
53 |
-
pixel blade m 3d rpg hack apk with vip features and free shopping<br />
|
54 |
-
pixel blade m hack apk for free shopping and keys and god mode<br />
|
55 |
-
pixel blade m latest version hack apk with god mode and vip<br />
|
56 |
-
pixel blade m vip hack apk download for android free shopping<br />
|
57 |
-
pixel blade m hack apk free shopping and unlimited keys and money<br />
|
58 |
-
pixel blade m 9.2.7 hack apk with god mode and vip features<br />
|
59 |
-
pixel blade m role-playing game hack apk free shopping and keys<br />
|
60 |
-
pixel blade m 3d graphics hack apk with unlimited money and god mode<br />
|
61 |
-
pixel blade m adventure game hack apk with vip features and free shopping<br />
|
62 |
-
pixel blade m free download hack apk with free shopping and keys and god mode<br />
|
63 |
-
download pixel blade m vip mod apk for android free shopping<br />
|
64 |
-
download pixel blade m mod apk free shopping and unlimited keys and money<br />
|
65 |
-
download pixel blade m 9.2.7 mod apk with god mode and vip features<br />
|
66 |
-
download pixel blade m role-playing game mod apk free shopping and keys<br />
|
67 |
-
download pixel blade m 3d graphics mod apk with unlimited money and god mode<br />
|
68 |
-
download pixel blade m adventure game mod apk with vip features and free shopping<br />
|
69 |
-
download pixel blade m latest version mod apk with god mode and vip features<br />
|
70 |
-
download pixel blade m vip hack apk for android free shopping and keys<br />
|
71 |
-
download pixel blade m hack apk free shopping and unlimited keys and money<br />
|
72 |
-
download pixel blade m 9.2.7 hack apk with god mode and vip features <br />
|
73 |
-
download pixel blade m role-playing game hack apk free shopping and keys <br />
|
74 |
-
download pixel blade m 3d graphics hack apk with unlimited money and god mode <br />
|
75 |
-
download pixel blade m adventure game hack apk with vip features and free shopping <br />
|
76 |
-
download pixel blade m latest version hack apk with god mode and vip features</p>
|
77 |
-
<h3>No ads and <h3>No ads and no root required</h3>
|
78 |
-
<p>Another reason why you should try Pixel Blade M VIP Mod APK Free Shopping is that it does not have any ads or require root access. Ads can be annoying and distracting when you are playing a game. They can also consume your data and battery. With this mod apk, you can enjoy the game without any interruptions or pop-ups. Moreover, you do not need to root your device to use this mod apk. Rooting can be risky and void your warranty. It can also expose your device to malware and viruses. With this mod apk, you can play the game safely and smoothly.</p>
|
79 |
-
<h3>Enjoy the pixel-style graphics and action-packed gameplay</h3>
|
80 |
-
<p>The last reason why you should try Pixel Blade M VIP Mod APK Free Shopping is that it has amazing pixel-style graphics and action-packed gameplay. If you are a fan of retro games and pixel art, you will love this game. The game has colorful and detailed graphics that create a nostalgic atmosphere. The game also has fast-paced and thrilling gameplay that will keep you hooked. You can slash, hack, and shoot your way through various dungeons and enemies. You can also use different skills and combos to unleash powerful attacks. The game is fun and addictive for anyone who loves action RPG games.</p>
|
81 |
-
<h2>Pros and cons of Pixel Blade M VIP Mod APK Free Shopping</h2>
|
82 |
-
<p>Like any other mod apk, Pixel Blade M VIP Mod APK Free Shopping has its pros and cons. Here are some of them:</p>
|
83 |
-
<h3>Pros</h3>
|
84 |
-
<ul>
|
85 |
-
<li><h4>Easy to use and install</h4>
|
86 |
-
<p>This mod apk is very easy to use and install. You just need to download the file from the link provided and follow the simple steps to install it on your device. You do not need any special skills or knowledge to use this mod apk.</p></li>
|
87 |
-
<li><h4>Free shopping for weapons and items</h4>
|
88 |
-
<p>This mod apk gives you free shopping for weapons and items in the game. You can buy any weapon or item you want without spending any money or gems. You can also upgrade your weapons and items for free. This will make your hero stronger and more equipped for the battles.</p></li>
|
89 |
-
<li><h4>Fun and addictive game</h4>
|
90 |
-
<p>This mod apk does not change the original game's features or gameplay. It only enhances them by giving you unlimited money and gems, free shopping, no ads, and no root required. You can still enjoy the pixel-style graphics and action-packed gameplay of the game. You can also play with other players online or offline in different modes. The game is fun and addictive for anyone who loves action RPG games.</p></li>
|
91 |
-
</ul>
|
92 |
-
<h3>Cons</h3>
|
93 |
-
<ul>
|
94 |
-
<li><h4>Not compatible with some devices</h4>
|
95 |
-
<p>This mod apk may not be compatible with some devices or Android versions. Some users have reported that the mod apk does not work on their devices or causes some errors or crashes. This may depend on the device's specifications, settings, or compatibility issues.</p></li>
|
96 |
-
<li><h4>May cause some glitches and bugs</h4>
|
97 |
-
<p>This mod apk may cause some glitches and bugs in the game. Some users have reported that the mod apk causes some problems with the game's graphics, sound, or performance. This may affect the game's quality or functionality.</p></li>
|
98 |
-
<li><h4>May not be updated regularly</h4>
|
99 |
-
<p>This mod apk may not be updated regularly by the developers or creators. This means that the mod apk may not work with the latest version of the game or may not have the latest features or improvements of the game. This may make the mod apk outdated or incompatible with the game.</p></li>
|
100 |
-
</ul>
|
101 |
-
<h2>Conclusion</h2>
|
102 |
-
<p>Pixel Blade M VIP Mod APK Free Shopping is a modified version of Pixel Blade M VIP that gives you unlimited money and gems, free shopping for weapons and items, no ads, and no root required. It is a great way to enjoy the pixel-style graphics and action-packed gameplay of Pixel Blade M VIP without spending real money or watching annoying ads. However, it also has some drawbacks, such as compatibility issues, glitches, bugs, or lack of updates. Therefore, you should use this mod apk at your own risk and discretion.</p>
|
103 |
-
<h2>FAQs</h2>
|
104 |
-
<ul>
|
105 |
-
<li><b>Q: Is Pixel Blade M VIP Mod APK Free Shopping safe to use?</b></li>
|
106 |
-
<li>A: Pixel Blade M VIP Mod APK Free Shopping is safe to use as long as you download it from a trusted source and scan it with an antivirus before installing it on your device. However, you should also be careful about the permissions you grant to the app and the data you share with it.</li>
|
107 |
-
<li><b>Q: Is Pixel Blade M VIP Mod APK Free <b>Q: Is Pixel Blade M VIP Mod APK Free Shopping legal to use?</b></li>
|
108 |
-
<li>A: Pixel Blade M VIP Mod APK Free Shopping is not legal to use as it violates the terms and conditions of the original game. It also infringes the intellectual property rights of the game developers and publishers. Therefore, you should use this mod apk at your own risk and responsibility.</li>
|
109 |
-
<li><b>Q: How can I update Pixel Blade M VIP Mod APK Free Shopping?</b></li>
|
110 |
-
<li>A: Pixel Blade M VIP Mod APK Free Shopping may not be updated regularly by the developers or creators. Therefore, you may not be able to update it from the app itself or from Google Play. You may need to check the source where you downloaded the mod apk for any updates or new versions.</li>
|
111 |
-
<li><b>Q: Can I play Pixel Blade M VIP Mod APK Free Shopping online or offline?</b></li>
|
112 |
-
<li>A: Pixel Blade M VIP Mod APK Free Shopping can be played both online and offline. However, some features or modes may require an internet connection to work properly. You may also need to connect to the internet to sync your progress or data with the game server.</li>
|
113 |
-
<li><b>Q: Can I play Pixel Blade M VIP Mod APK Free Shopping with other players?</b></li>
|
114 |
-
<li>A: Pixel Blade M VIP Mod APK Free Shopping allows you to play with other players online or offline in different modes, such as PVP mode, raid mode, or guild mode. However, you may not be able to play with players who are using the original game or a different mod apk. You may also face some issues or errors when playing with other players due to the mod apk's modifications.</li>
|
115 |
-
</ul></p> 401be4b1e0<br />
|
116 |
-
<br />
|
117 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/4Taps/SadTalker/src/face3d/models/arcface_torch/configs/ms1mv3_r34.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
from easydict import EasyDict as edict
|
2 |
-
|
3 |
-
# make training faster
|
4 |
-
# our RAM is 256G
|
5 |
-
# mount -t tmpfs -o size=140G tmpfs /train_tmp
|
6 |
-
|
7 |
-
config = edict()
|
8 |
-
config.loss = "arcface"
|
9 |
-
config.network = "r34"
|
10 |
-
config.resume = False
|
11 |
-
config.output = None
|
12 |
-
config.embedding_size = 512
|
13 |
-
config.sample_rate = 1.0
|
14 |
-
config.fp16 = True
|
15 |
-
config.momentum = 0.9
|
16 |
-
config.weight_decay = 5e-4
|
17 |
-
config.batch_size = 128
|
18 |
-
config.lr = 0.1 # batch size is 512
|
19 |
-
|
20 |
-
config.rec = "/train_tmp/ms1m-retinaface-t1"
|
21 |
-
config.num_classes = 93431
|
22 |
-
config.num_image = 5179510
|
23 |
-
config.num_epoch = 25
|
24 |
-
config.warmup_epoch = -1
|
25 |
-
config.decay_epoch = [10, 16, 22]
|
26 |
-
config.val_targets = ["lfw", "cfp_fp", "agedb_30"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/A00001/bingothoo/src/components/ui/select.tsx
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
'use client'
|
2 |
-
|
3 |
-
import * as React from 'react'
|
4 |
-
import * as SelectPrimitive from '@radix-ui/react-select'
|
5 |
-
|
6 |
-
import { cn } from '@/lib/utils'
|
7 |
-
import {
|
8 |
-
IconArrowDown,
|
9 |
-
IconCheck,
|
10 |
-
IconChevronUpDown
|
11 |
-
} from '@/components/ui/icons'
|
12 |
-
|
13 |
-
const Select = SelectPrimitive.Root
|
14 |
-
|
15 |
-
const SelectGroup = SelectPrimitive.Group
|
16 |
-
|
17 |
-
const SelectValue = SelectPrimitive.Value
|
18 |
-
|
19 |
-
const SelectTrigger = React.forwardRef<
|
20 |
-
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
21 |
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
22 |
-
>(({ className, children, ...props }, ref) => (
|
23 |
-
<SelectPrimitive.Trigger
|
24 |
-
ref={ref}
|
25 |
-
className={cn(
|
26 |
-
'flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
27 |
-
className
|
28 |
-
)}
|
29 |
-
{...props}
|
30 |
-
>
|
31 |
-
{children}
|
32 |
-
<SelectPrimitive.Icon asChild>
|
33 |
-
<IconChevronUpDown className="opacity-50" />
|
34 |
-
</SelectPrimitive.Icon>
|
35 |
-
</SelectPrimitive.Trigger>
|
36 |
-
))
|
37 |
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
38 |
-
|
39 |
-
const SelectContent = React.forwardRef<
|
40 |
-
React.ElementRef<typeof SelectPrimitive.Content>,
|
41 |
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
42 |
-
>(({ className, children, position = 'popper', ...props }, ref) => (
|
43 |
-
<SelectPrimitive.Portal>
|
44 |
-
<SelectPrimitive.Content
|
45 |
-
ref={ref}
|
46 |
-
className={cn(
|
47 |
-
'relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80',
|
48 |
-
position === 'popper' && 'translate-y-1',
|
49 |
-
className
|
50 |
-
)}
|
51 |
-
position={position}
|
52 |
-
{...props}
|
53 |
-
>
|
54 |
-
<SelectPrimitive.Viewport
|
55 |
-
className={cn(
|
56 |
-
'p-1',
|
57 |
-
position === 'popper' &&
|
58 |
-
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'
|
59 |
-
)}
|
60 |
-
>
|
61 |
-
{children}
|
62 |
-
</SelectPrimitive.Viewport>
|
63 |
-
</SelectPrimitive.Content>
|
64 |
-
</SelectPrimitive.Portal>
|
65 |
-
))
|
66 |
-
SelectContent.displayName = SelectPrimitive.Content.displayName
|
67 |
-
|
68 |
-
const SelectLabel = React.forwardRef<
|
69 |
-
React.ElementRef<typeof SelectPrimitive.Label>,
|
70 |
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
71 |
-
>(({ className, ...props }, ref) => (
|
72 |
-
<SelectPrimitive.Label
|
73 |
-
ref={ref}
|
74 |
-
className={cn('py-1.5 pl-8 pr-2 text-sm font-semibold', className)}
|
75 |
-
{...props}
|
76 |
-
/>
|
77 |
-
))
|
78 |
-
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
79 |
-
|
80 |
-
const SelectItem = React.forwardRef<
|
81 |
-
React.ElementRef<typeof SelectPrimitive.Item>,
|
82 |
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
83 |
-
>(({ className, children, ...props }, ref) => (
|
84 |
-
<SelectPrimitive.Item
|
85 |
-
ref={ref}
|
86 |
-
className={cn(
|
87 |
-
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
88 |
-
className
|
89 |
-
)}
|
90 |
-
{...props}
|
91 |
-
>
|
92 |
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
93 |
-
<SelectPrimitive.ItemIndicator>
|
94 |
-
<IconCheck className="h-4 w-4" />
|
95 |
-
</SelectPrimitive.ItemIndicator>
|
96 |
-
</span>
|
97 |
-
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
98 |
-
</SelectPrimitive.Item>
|
99 |
-
))
|
100 |
-
SelectItem.displayName = SelectPrimitive.Item.displayName
|
101 |
-
|
102 |
-
const SelectSeparator = React.forwardRef<
|
103 |
-
React.ElementRef<typeof SelectPrimitive.Separator>,
|
104 |
-
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
105 |
-
>(({ className, ...props }, ref) => (
|
106 |
-
<SelectPrimitive.Separator
|
107 |
-
ref={ref}
|
108 |
-
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
109 |
-
{...props}
|
110 |
-
/>
|
111 |
-
))
|
112 |
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
113 |
-
|
114 |
-
export {
|
115 |
-
Select,
|
116 |
-
SelectGroup,
|
117 |
-
SelectValue,
|
118 |
-
SelectTrigger,
|
119 |
-
SelectContent,
|
120 |
-
SelectLabel,
|
121 |
-
SelectItem,
|
122 |
-
SelectSeparator
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/A666sxr/Genshin_TTS/transforms.py
DELETED
@@ -1,193 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
from torch.nn import functional as F
|
3 |
-
|
4 |
-
import numpy as np
|
5 |
-
|
6 |
-
|
7 |
-
DEFAULT_MIN_BIN_WIDTH = 1e-3
|
8 |
-
DEFAULT_MIN_BIN_HEIGHT = 1e-3
|
9 |
-
DEFAULT_MIN_DERIVATIVE = 1e-3
|
10 |
-
|
11 |
-
|
12 |
-
def piecewise_rational_quadratic_transform(inputs,
|
13 |
-
unnormalized_widths,
|
14 |
-
unnormalized_heights,
|
15 |
-
unnormalized_derivatives,
|
16 |
-
inverse=False,
|
17 |
-
tails=None,
|
18 |
-
tail_bound=1.,
|
19 |
-
min_bin_width=DEFAULT_MIN_BIN_WIDTH,
|
20 |
-
min_bin_height=DEFAULT_MIN_BIN_HEIGHT,
|
21 |
-
min_derivative=DEFAULT_MIN_DERIVATIVE):
|
22 |
-
|
23 |
-
if tails is None:
|
24 |
-
spline_fn = rational_quadratic_spline
|
25 |
-
spline_kwargs = {}
|
26 |
-
else:
|
27 |
-
spline_fn = unconstrained_rational_quadratic_spline
|
28 |
-
spline_kwargs = {
|
29 |
-
'tails': tails,
|
30 |
-
'tail_bound': tail_bound
|
31 |
-
}
|
32 |
-
|
33 |
-
outputs, logabsdet = spline_fn(
|
34 |
-
inputs=inputs,
|
35 |
-
unnormalized_widths=unnormalized_widths,
|
36 |
-
unnormalized_heights=unnormalized_heights,
|
37 |
-
unnormalized_derivatives=unnormalized_derivatives,
|
38 |
-
inverse=inverse,
|
39 |
-
min_bin_width=min_bin_width,
|
40 |
-
min_bin_height=min_bin_height,
|
41 |
-
min_derivative=min_derivative,
|
42 |
-
**spline_kwargs
|
43 |
-
)
|
44 |
-
return outputs, logabsdet
|
45 |
-
|
46 |
-
|
47 |
-
def searchsorted(bin_locations, inputs, eps=1e-6):
|
48 |
-
bin_locations[..., -1] += eps
|
49 |
-
return torch.sum(
|
50 |
-
inputs[..., None] >= bin_locations,
|
51 |
-
dim=-1
|
52 |
-
) - 1
|
53 |
-
|
54 |
-
|
55 |
-
def unconstrained_rational_quadratic_spline(inputs,
|
56 |
-
unnormalized_widths,
|
57 |
-
unnormalized_heights,
|
58 |
-
unnormalized_derivatives,
|
59 |
-
inverse=False,
|
60 |
-
tails='linear',
|
61 |
-
tail_bound=1.,
|
62 |
-
min_bin_width=DEFAULT_MIN_BIN_WIDTH,
|
63 |
-
min_bin_height=DEFAULT_MIN_BIN_HEIGHT,
|
64 |
-
min_derivative=DEFAULT_MIN_DERIVATIVE):
|
65 |
-
inside_interval_mask = (inputs >= -tail_bound) & (inputs <= tail_bound)
|
66 |
-
outside_interval_mask = ~inside_interval_mask
|
67 |
-
|
68 |
-
outputs = torch.zeros_like(inputs)
|
69 |
-
logabsdet = torch.zeros_like(inputs)
|
70 |
-
|
71 |
-
if tails == 'linear':
|
72 |
-
unnormalized_derivatives = F.pad(unnormalized_derivatives, pad=(1, 1))
|
73 |
-
constant = np.log(np.exp(1 - min_derivative) - 1)
|
74 |
-
unnormalized_derivatives[..., 0] = constant
|
75 |
-
unnormalized_derivatives[..., -1] = constant
|
76 |
-
|
77 |
-
outputs[outside_interval_mask] = inputs[outside_interval_mask]
|
78 |
-
logabsdet[outside_interval_mask] = 0
|
79 |
-
else:
|
80 |
-
raise RuntimeError('{} tails are not implemented.'.format(tails))
|
81 |
-
|
82 |
-
outputs[inside_interval_mask], logabsdet[inside_interval_mask] = rational_quadratic_spline(
|
83 |
-
inputs=inputs[inside_interval_mask],
|
84 |
-
unnormalized_widths=unnormalized_widths[inside_interval_mask, :],
|
85 |
-
unnormalized_heights=unnormalized_heights[inside_interval_mask, :],
|
86 |
-
unnormalized_derivatives=unnormalized_derivatives[inside_interval_mask, :],
|
87 |
-
inverse=inverse,
|
88 |
-
left=-tail_bound, right=tail_bound, bottom=-tail_bound, top=tail_bound,
|
89 |
-
min_bin_width=min_bin_width,
|
90 |
-
min_bin_height=min_bin_height,
|
91 |
-
min_derivative=min_derivative
|
92 |
-
)
|
93 |
-
|
94 |
-
return outputs, logabsdet
|
95 |
-
|
96 |
-
def rational_quadratic_spline(inputs,
|
97 |
-
unnormalized_widths,
|
98 |
-
unnormalized_heights,
|
99 |
-
unnormalized_derivatives,
|
100 |
-
inverse=False,
|
101 |
-
left=0., right=1., bottom=0., top=1.,
|
102 |
-
min_bin_width=DEFAULT_MIN_BIN_WIDTH,
|
103 |
-
min_bin_height=DEFAULT_MIN_BIN_HEIGHT,
|
104 |
-
min_derivative=DEFAULT_MIN_DERIVATIVE):
|
105 |
-
if torch.min(inputs) < left or torch.max(inputs) > right:
|
106 |
-
raise ValueError('Input to a transform is not within its domain')
|
107 |
-
|
108 |
-
num_bins = unnormalized_widths.shape[-1]
|
109 |
-
|
110 |
-
if min_bin_width * num_bins > 1.0:
|
111 |
-
raise ValueError('Minimal bin width too large for the number of bins')
|
112 |
-
if min_bin_height * num_bins > 1.0:
|
113 |
-
raise ValueError('Minimal bin height too large for the number of bins')
|
114 |
-
|
115 |
-
widths = F.softmax(unnormalized_widths, dim=-1)
|
116 |
-
widths = min_bin_width + (1 - min_bin_width * num_bins) * widths
|
117 |
-
cumwidths = torch.cumsum(widths, dim=-1)
|
118 |
-
cumwidths = F.pad(cumwidths, pad=(1, 0), mode='constant', value=0.0)
|
119 |
-
cumwidths = (right - left) * cumwidths + left
|
120 |
-
cumwidths[..., 0] = left
|
121 |
-
cumwidths[..., -1] = right
|
122 |
-
widths = cumwidths[..., 1:] - cumwidths[..., :-1]
|
123 |
-
|
124 |
-
derivatives = min_derivative + F.softplus(unnormalized_derivatives)
|
125 |
-
|
126 |
-
heights = F.softmax(unnormalized_heights, dim=-1)
|
127 |
-
heights = min_bin_height + (1 - min_bin_height * num_bins) * heights
|
128 |
-
cumheights = torch.cumsum(heights, dim=-1)
|
129 |
-
cumheights = F.pad(cumheights, pad=(1, 0), mode='constant', value=0.0)
|
130 |
-
cumheights = (top - bottom) * cumheights + bottom
|
131 |
-
cumheights[..., 0] = bottom
|
132 |
-
cumheights[..., -1] = top
|
133 |
-
heights = cumheights[..., 1:] - cumheights[..., :-1]
|
134 |
-
|
135 |
-
if inverse:
|
136 |
-
bin_idx = searchsorted(cumheights, inputs)[..., None]
|
137 |
-
else:
|
138 |
-
bin_idx = searchsorted(cumwidths, inputs)[..., None]
|
139 |
-
|
140 |
-
input_cumwidths = cumwidths.gather(-1, bin_idx)[..., 0]
|
141 |
-
input_bin_widths = widths.gather(-1, bin_idx)[..., 0]
|
142 |
-
|
143 |
-
input_cumheights = cumheights.gather(-1, bin_idx)[..., 0]
|
144 |
-
delta = heights / widths
|
145 |
-
input_delta = delta.gather(-1, bin_idx)[..., 0]
|
146 |
-
|
147 |
-
input_derivatives = derivatives.gather(-1, bin_idx)[..., 0]
|
148 |
-
input_derivatives_plus_one = derivatives[..., 1:].gather(-1, bin_idx)[..., 0]
|
149 |
-
|
150 |
-
input_heights = heights.gather(-1, bin_idx)[..., 0]
|
151 |
-
|
152 |
-
if inverse:
|
153 |
-
a = (((inputs - input_cumheights) * (input_derivatives
|
154 |
-
+ input_derivatives_plus_one
|
155 |
-
- 2 * input_delta)
|
156 |
-
+ input_heights * (input_delta - input_derivatives)))
|
157 |
-
b = (input_heights * input_derivatives
|
158 |
-
- (inputs - input_cumheights) * (input_derivatives
|
159 |
-
+ input_derivatives_plus_one
|
160 |
-
- 2 * input_delta))
|
161 |
-
c = - input_delta * (inputs - input_cumheights)
|
162 |
-
|
163 |
-
discriminant = b.pow(2) - 4 * a * c
|
164 |
-
assert (discriminant >= 0).all()
|
165 |
-
|
166 |
-
root = (2 * c) / (-b - torch.sqrt(discriminant))
|
167 |
-
outputs = root * input_bin_widths + input_cumwidths
|
168 |
-
|
169 |
-
theta_one_minus_theta = root * (1 - root)
|
170 |
-
denominator = input_delta + ((input_derivatives + input_derivatives_plus_one - 2 * input_delta)
|
171 |
-
* theta_one_minus_theta)
|
172 |
-
derivative_numerator = input_delta.pow(2) * (input_derivatives_plus_one * root.pow(2)
|
173 |
-
+ 2 * input_delta * theta_one_minus_theta
|
174 |
-
+ input_derivatives * (1 - root).pow(2))
|
175 |
-
logabsdet = torch.log(derivative_numerator) - 2 * torch.log(denominator)
|
176 |
-
|
177 |
-
return outputs, -logabsdet
|
178 |
-
else:
|
179 |
-
theta = (inputs - input_cumwidths) / input_bin_widths
|
180 |
-
theta_one_minus_theta = theta * (1 - theta)
|
181 |
-
|
182 |
-
numerator = input_heights * (input_delta * theta.pow(2)
|
183 |
-
+ input_derivatives * theta_one_minus_theta)
|
184 |
-
denominator = input_delta + ((input_derivatives + input_derivatives_plus_one - 2 * input_delta)
|
185 |
-
* theta_one_minus_theta)
|
186 |
-
outputs = input_cumheights + numerator / denominator
|
187 |
-
|
188 |
-
derivative_numerator = input_delta.pow(2) * (input_derivatives_plus_one * theta.pow(2)
|
189 |
-
+ 2 * input_delta * theta_one_minus_theta
|
190 |
-
+ input_derivatives * (1 - theta).pow(2))
|
191 |
-
logabsdet = torch.log(derivative_numerator) - 2 * torch.log(denominator)
|
192 |
-
|
193 |
-
return outputs, logabsdet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AIWaves/Software_Company/src/agents/State.py
DELETED
@@ -1,142 +0,0 @@
|
|
1 |
-
from Component import *
|
2 |
-
|
3 |
-
|
4 |
-
class State:
|
5 |
-
"""
|
6 |
-
Sub-scenes of role activities, responsible for storing the tasks that each role needs to do
|
7 |
-
"""
|
8 |
-
def __init__(self, **kwargs):
|
9 |
-
self.next_states = {}
|
10 |
-
self.name = kwargs["name"]
|
11 |
-
|
12 |
-
self.environment_prompt = (
|
13 |
-
kwargs["environment_prompt"] if "environment_prompt" in kwargs else ""
|
14 |
-
)
|
15 |
-
|
16 |
-
self.roles = kwargs["roles"] if "roles" in kwargs else (list(kwargs["agent_states"].keys()) if "agent_states" in kwargs else [0])
|
17 |
-
if len(self.roles) == 0:
|
18 |
-
self.roles = [0]
|
19 |
-
self.begin_role = (
|
20 |
-
kwargs["begin_role"] if "begin_role" in kwargs else self.roles[0]
|
21 |
-
)
|
22 |
-
self.begin_query = kwargs["begin_query"] if "begin_query" in kwargs else None
|
23 |
-
|
24 |
-
self.is_begin = True
|
25 |
-
|
26 |
-
self.summary_prompt = (
|
27 |
-
kwargs["summary_prompt"] if "summary_prompt" in kwargs else None
|
28 |
-
)
|
29 |
-
self.current_role = self.begin_role
|
30 |
-
self.components = (
|
31 |
-
self.init_components(kwargs["agent_states"])
|
32 |
-
if "agent_states" in kwargs
|
33 |
-
else {}
|
34 |
-
)
|
35 |
-
self.index = (
|
36 |
-
self.roles.index(self.begin_role) if self.begin_role in self.roles else 0
|
37 |
-
)
|
38 |
-
self.chat_nums = 0
|
39 |
-
|
40 |
-
def init_components(self, agent_states_dict: dict):
|
41 |
-
agent_states = {}
|
42 |
-
for role, components in agent_states_dict.items():
|
43 |
-
component_dict = {}
|
44 |
-
for component, component_args in components.items():
|
45 |
-
if component:
|
46 |
-
# "role" "style"
|
47 |
-
if component == "style":
|
48 |
-
component_dict["style"] = StyleComponent(component_args["role"])
|
49 |
-
|
50 |
-
# "task"
|
51 |
-
elif component == "task":
|
52 |
-
component_dict["task"] = TaskComponent(component_args["task"])
|
53 |
-
|
54 |
-
# "rule"
|
55 |
-
elif component == "rule":
|
56 |
-
component_dict["rule"] = RuleComponent(component_args["rule"])
|
57 |
-
|
58 |
-
# "demonstration"
|
59 |
-
elif component == "demonstrations":
|
60 |
-
component_dict["demonstrations"] = DemonstrationComponent(
|
61 |
-
component_args["demonstrations"]
|
62 |
-
)
|
63 |
-
|
64 |
-
# "output"
|
65 |
-
elif component == "output":
|
66 |
-
component_dict["output"] = OutputComponent(
|
67 |
-
component_args["output"]
|
68 |
-
)
|
69 |
-
|
70 |
-
elif component == "last":
|
71 |
-
component_dict["last"] = LastComponent(
|
72 |
-
component_args["last_prompt"]
|
73 |
-
)
|
74 |
-
|
75 |
-
# "demonstrations"
|
76 |
-
elif component == "cot":
|
77 |
-
component_dict["cot"] = CoTComponent(
|
78 |
-
component_args["demonstrations"]
|
79 |
-
)
|
80 |
-
elif component == "CustomizeComponent":
|
81 |
-
component_dict["CustomizeComponent"] = CustomizeComponent(
|
82 |
-
component_args["template"], component_args["keywords"]
|
83 |
-
)
|
84 |
-
|
85 |
-
elif component == "system" :
|
86 |
-
component_dict["system"] = SystemComponent(
|
87 |
-
component_args["system_prompt"]
|
88 |
-
)
|
89 |
-
|
90 |
-
# =================================================================================#
|
91 |
-
|
92 |
-
# "output"
|
93 |
-
elif component == "StaticComponent":
|
94 |
-
component_dict["StaticComponent"] = StaticComponent(
|
95 |
-
component_args["output"]
|
96 |
-
)
|
97 |
-
|
98 |
-
# "top_k" "type" "knowledge_base" "system_prompt" "last_prompt"
|
99 |
-
elif component == "KnowledgeBaseComponent":
|
100 |
-
component_dict["tool"] = KnowledgeBaseComponent(
|
101 |
-
component_args["top_k"],
|
102 |
-
component_args["type"],
|
103 |
-
component_args["knowledge_path"],
|
104 |
-
)
|
105 |
-
|
106 |
-
elif component == "CategoryRequirementsComponent":
|
107 |
-
component_dict[
|
108 |
-
"CategoryRequirementsComponent"
|
109 |
-
] = CategoryRequirementsComponent(
|
110 |
-
component_args["information_path"]
|
111 |
-
)
|
112 |
-
|
113 |
-
elif component == "FunctionComponent":
|
114 |
-
component_dict["FunctionComponent"] = FunctionComponent(component_args[""])
|
115 |
-
# "short_memory_extract_words" "long_memory_extract_words" "system_prompt" "last_prompt"
|
116 |
-
elif component == "ExtractComponent":
|
117 |
-
component_dict["ExtractComponent"] = ExtractComponent(
|
118 |
-
component_args["extract_words"],
|
119 |
-
component_args["system_prompt"],
|
120 |
-
component_args["last_prompt"],
|
121 |
-
)
|
122 |
-
elif component == "WebSearchComponent":
|
123 |
-
component_dict["WebSearchComponent"] = WebSearchComponent(
|
124 |
-
component_args["engine_name"], component_args["api"]
|
125 |
-
)
|
126 |
-
elif component == "WebCrawlComponent":
|
127 |
-
component_dict["WebCrawlComponent"] = WebCrawlComponent(
|
128 |
-
component_args["name"]
|
129 |
-
)
|
130 |
-
|
131 |
-
elif component == "CodeComponent":
|
132 |
-
component_dict["CodeComponent"] = CodeComponent(
|
133 |
-
component_args["file_name"], component_args["keyword"]
|
134 |
-
)
|
135 |
-
|
136 |
-
# ====================================================
|
137 |
-
else:
|
138 |
-
continue
|
139 |
-
|
140 |
-
agent_states[role] = component_dict
|
141 |
-
|
142 |
-
return agent_states
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Abhilashvj/planogram-compliance/segment/train.py
DELETED
@@ -1,1104 +0,0 @@
|
|
1 |
-
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
|
2 |
-
"""
|
3 |
-
Train a YOLOv5 segment model on a segment dataset
|
4 |
-
Models and datasets download automatically from the latest YOLOv5 release.
|
5 |
-
|
6 |
-
Usage - Single-GPU training:
|
7 |
-
$ python segment/train.py --data coco128-seg.yaml --weights yolov5s-seg.pt --img 640 # from pretrained (recommended)
|
8 |
-
$ python segment/train.py --data coco128-seg.yaml --weights '' --cfg yolov5s-seg.yaml --img 640 # from scratch
|
9 |
-
|
10 |
-
Usage - Multi-GPU DDP training:
|
11 |
-
$ python -m torch.distributed.run --nproc_per_node 4 --master_port 1 segment/train.py --data coco128-seg.yaml --weights yolov5s-seg.pt --img 640 --device 0,1,2,3
|
12 |
-
|
13 |
-
Models: https://github.com/ultralytics/yolov5/tree/master/models
|
14 |
-
Datasets: https://github.com/ultralytics/yolov5/tree/master/data
|
15 |
-
Tutorial: https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data
|
16 |
-
"""
|
17 |
-
|
18 |
-
import argparse
|
19 |
-
import math
|
20 |
-
import os
|
21 |
-
import random
|
22 |
-
import sys
|
23 |
-
import time
|
24 |
-
from copy import deepcopy
|
25 |
-
from datetime import datetime
|
26 |
-
from pathlib import Path
|
27 |
-
|
28 |
-
import numpy as np
|
29 |
-
import torch
|
30 |
-
import torch.distributed as dist
|
31 |
-
import torch.nn as nn
|
32 |
-
import yaml
|
33 |
-
from torch.optim import lr_scheduler
|
34 |
-
from tqdm import tqdm
|
35 |
-
|
36 |
-
FILE = Path(__file__).resolve()
|
37 |
-
ROOT = FILE.parents[1] # YOLOv5 root directory
|
38 |
-
if str(ROOT) not in sys.path:
|
39 |
-
sys.path.append(str(ROOT)) # add ROOT to PATH
|
40 |
-
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
41 |
-
|
42 |
-
import segment.val as validate # for end-of-epoch mAP
|
43 |
-
from models.experimental import attempt_load
|
44 |
-
from models.yolo import SegmentationModel
|
45 |
-
from utils.autoanchor import check_anchors
|
46 |
-
from utils.autobatch import check_train_batch_size
|
47 |
-
from utils.callbacks import Callbacks
|
48 |
-
from utils.downloads import attempt_download, is_url
|
49 |
-
from utils.general import (
|
50 |
-
LOGGER,
|
51 |
-
TQDM_BAR_FORMAT,
|
52 |
-
check_amp,
|
53 |
-
check_dataset,
|
54 |
-
check_file,
|
55 |
-
check_git_info,
|
56 |
-
check_git_status,
|
57 |
-
check_img_size,
|
58 |
-
check_requirements,
|
59 |
-
check_suffix,
|
60 |
-
check_yaml,
|
61 |
-
colorstr,
|
62 |
-
get_latest_run,
|
63 |
-
increment_path,
|
64 |
-
init_seeds,
|
65 |
-
intersect_dicts,
|
66 |
-
labels_to_class_weights,
|
67 |
-
labels_to_image_weights,
|
68 |
-
one_cycle,
|
69 |
-
print_args,
|
70 |
-
print_mutation,
|
71 |
-
strip_optimizer,
|
72 |
-
yaml_save,
|
73 |
-
)
|
74 |
-
from utils.loggers import GenericLogger
|
75 |
-
from utils.plots import plot_evolve, plot_labels
|
76 |
-
from utils.segment.dataloaders import create_dataloader
|
77 |
-
from utils.segment.loss import ComputeLoss
|
78 |
-
from utils.segment.metrics import KEYS, fitness
|
79 |
-
from utils.segment.plots import plot_images_and_masks, plot_results_with_masks
|
80 |
-
from utils.torch_utils import (
|
81 |
-
EarlyStopping,
|
82 |
-
ModelEMA,
|
83 |
-
de_parallel,
|
84 |
-
select_device,
|
85 |
-
smart_DDP,
|
86 |
-
smart_optimizer,
|
87 |
-
smart_resume,
|
88 |
-
torch_distributed_zero_first,
|
89 |
-
)
|
90 |
-
|
91 |
-
LOCAL_RANK = int(
|
92 |
-
os.getenv("LOCAL_RANK", -1)
|
93 |
-
) # https://pytorch.org/docs/stable/elastic/run.html
|
94 |
-
RANK = int(os.getenv("RANK", -1))
|
95 |
-
WORLD_SIZE = int(os.getenv("WORLD_SIZE", 1))
|
96 |
-
GIT_INFO = check_git_info()
|
97 |
-
|
98 |
-
|
99 |
-
def train(
|
100 |
-
hyp, opt, device, callbacks
|
101 |
-
): # hyp is path/to/hyp.yaml or hyp dictionary
|
102 |
-
(
|
103 |
-
save_dir,
|
104 |
-
epochs,
|
105 |
-
batch_size,
|
106 |
-
weights,
|
107 |
-
single_cls,
|
108 |
-
evolve,
|
109 |
-
data,
|
110 |
-
cfg,
|
111 |
-
resume,
|
112 |
-
noval,
|
113 |
-
nosave,
|
114 |
-
workers,
|
115 |
-
freeze,
|
116 |
-
mask_ratio,
|
117 |
-
) = (
|
118 |
-
Path(opt.save_dir),
|
119 |
-
opt.epochs,
|
120 |
-
opt.batch_size,
|
121 |
-
opt.weights,
|
122 |
-
opt.single_cls,
|
123 |
-
opt.evolve,
|
124 |
-
opt.data,
|
125 |
-
opt.cfg,
|
126 |
-
opt.resume,
|
127 |
-
opt.noval,
|
128 |
-
opt.nosave,
|
129 |
-
opt.workers,
|
130 |
-
opt.freeze,
|
131 |
-
opt.mask_ratio,
|
132 |
-
)
|
133 |
-
# callbacks.run('on_pretrain_routine_start')
|
134 |
-
|
135 |
-
# Directories
|
136 |
-
w = save_dir / "weights" # weights dir
|
137 |
-
(w.parent if evolve else w).mkdir(parents=True, exist_ok=True) # make dir
|
138 |
-
last, best = w / "last.pt", w / "best.pt"
|
139 |
-
|
140 |
-
# Hyperparameters
|
141 |
-
if isinstance(hyp, str):
|
142 |
-
with open(hyp, errors="ignore") as f:
|
143 |
-
hyp = yaml.safe_load(f) # load hyps dict
|
144 |
-
LOGGER.info(
|
145 |
-
colorstr("hyperparameters: ")
|
146 |
-
+ ", ".join(f"{k}={v}" for k, v in hyp.items())
|
147 |
-
)
|
148 |
-
opt.hyp = hyp.copy() # for saving hyps to checkpoints
|
149 |
-
|
150 |
-
# Save run settings
|
151 |
-
if not evolve:
|
152 |
-
yaml_save(save_dir / "hyp.yaml", hyp)
|
153 |
-
yaml_save(save_dir / "opt.yaml", vars(opt))
|
154 |
-
|
155 |
-
# Loggers
|
156 |
-
data_dict = None
|
157 |
-
if RANK in {-1, 0}:
|
158 |
-
logger = GenericLogger(opt=opt, console_logger=LOGGER)
|
159 |
-
|
160 |
-
# Config
|
161 |
-
plots = not evolve and not opt.noplots # create plots
|
162 |
-
overlap = not opt.no_overlap
|
163 |
-
cuda = device.type != "cpu"
|
164 |
-
init_seeds(opt.seed + 1 + RANK, deterministic=True)
|
165 |
-
with torch_distributed_zero_first(LOCAL_RANK):
|
166 |
-
data_dict = data_dict or check_dataset(data) # check if None
|
167 |
-
train_path, val_path = data_dict["train"], data_dict["val"]
|
168 |
-
nc = 1 if single_cls else int(data_dict["nc"]) # number of classes
|
169 |
-
names = (
|
170 |
-
{0: "item"}
|
171 |
-
if single_cls and len(data_dict["names"]) != 1
|
172 |
-
else data_dict["names"]
|
173 |
-
) # class names
|
174 |
-
is_coco = isinstance(val_path, str) and val_path.endswith(
|
175 |
-
"coco/val2017.txt"
|
176 |
-
) # COCO dataset
|
177 |
-
|
178 |
-
# Model
|
179 |
-
check_suffix(weights, ".pt") # check weights
|
180 |
-
pretrained = weights.endswith(".pt")
|
181 |
-
if pretrained:
|
182 |
-
with torch_distributed_zero_first(LOCAL_RANK):
|
183 |
-
weights = attempt_download(
|
184 |
-
weights
|
185 |
-
) # download if not found locally
|
186 |
-
ckpt = torch.load(
|
187 |
-
weights, map_location="cpu"
|
188 |
-
) # load checkpoint to CPU to avoid CUDA memory leak
|
189 |
-
model = SegmentationModel(
|
190 |
-
cfg or ckpt["model"].yaml, ch=3, nc=nc, anchors=hyp.get("anchors")
|
191 |
-
).to(device)
|
192 |
-
exclude = (
|
193 |
-
["anchor"] if (cfg or hyp.get("anchors")) and not resume else []
|
194 |
-
) # exclude keys
|
195 |
-
csd = (
|
196 |
-
ckpt["model"].float().state_dict()
|
197 |
-
) # checkpoint state_dict as FP32
|
198 |
-
csd = intersect_dicts(
|
199 |
-
csd, model.state_dict(), exclude=exclude
|
200 |
-
) # intersect
|
201 |
-
model.load_state_dict(csd, strict=False) # load
|
202 |
-
LOGGER.info(
|
203 |
-
f"Transferred {len(csd)}/{len(model.state_dict())} items from {weights}"
|
204 |
-
) # report
|
205 |
-
else:
|
206 |
-
model = SegmentationModel(
|
207 |
-
cfg, ch=3, nc=nc, anchors=hyp.get("anchors")
|
208 |
-
).to(
|
209 |
-
device
|
210 |
-
) # create
|
211 |
-
amp = check_amp(model) # check AMP
|
212 |
-
|
213 |
-
# Freeze
|
214 |
-
freeze = [
|
215 |
-
f"model.{x}."
|
216 |
-
for x in (freeze if len(freeze) > 1 else range(freeze[0]))
|
217 |
-
] # layers to freeze
|
218 |
-
for k, v in model.named_parameters():
|
219 |
-
v.requires_grad = True # train all layers
|
220 |
-
# v.register_hook(lambda x: torch.nan_to_num(x)) # NaN to 0 (commented for erratic training results)
|
221 |
-
if any(x in k for x in freeze):
|
222 |
-
LOGGER.info(f"freezing {k}")
|
223 |
-
v.requires_grad = False
|
224 |
-
|
225 |
-
# Image size
|
226 |
-
gs = max(int(model.stride.max()), 32) # grid size (max stride)
|
227 |
-
imgsz = check_img_size(
|
228 |
-
opt.imgsz, gs, floor=gs * 2
|
229 |
-
) # verify imgsz is gs-multiple
|
230 |
-
|
231 |
-
# Batch size
|
232 |
-
if (
|
233 |
-
RANK == -1 and batch_size == -1
|
234 |
-
): # single-GPU only, estimate best batch size
|
235 |
-
batch_size = check_train_batch_size(model, imgsz, amp)
|
236 |
-
logger.update_params({"batch_size": batch_size})
|
237 |
-
# loggers.on_params_update({"batch_size": batch_size})
|
238 |
-
|
239 |
-
# Optimizer
|
240 |
-
nbs = 64 # nominal batch size
|
241 |
-
accumulate = max(
|
242 |
-
round(nbs / batch_size), 1
|
243 |
-
) # accumulate loss before optimizing
|
244 |
-
hyp["weight_decay"] *= batch_size * accumulate / nbs # scale weight_decay
|
245 |
-
optimizer = smart_optimizer(
|
246 |
-
model, opt.optimizer, hyp["lr0"], hyp["momentum"], hyp["weight_decay"]
|
247 |
-
)
|
248 |
-
|
249 |
-
# Scheduler
|
250 |
-
if opt.cos_lr:
|
251 |
-
lf = one_cycle(1, hyp["lrf"], epochs) # cosine 1->hyp['lrf']
|
252 |
-
else:
|
253 |
-
lf = (
|
254 |
-
lambda x: (1 - x / epochs) * (1.0 - hyp["lrf"]) + hyp["lrf"]
|
255 |
-
) # linear
|
256 |
-
scheduler = lr_scheduler.LambdaLR(
|
257 |
-
optimizer, lr_lambda=lf
|
258 |
-
) # plot_lr_scheduler(optimizer, scheduler, epochs)
|
259 |
-
|
260 |
-
# EMA
|
261 |
-
ema = ModelEMA(model) if RANK in {-1, 0} else None
|
262 |
-
|
263 |
-
# Resume
|
264 |
-
best_fitness, start_epoch = 0.0, 0
|
265 |
-
if pretrained:
|
266 |
-
if resume:
|
267 |
-
best_fitness, start_epoch, epochs = smart_resume(
|
268 |
-
ckpt, optimizer, ema, weights, epochs, resume
|
269 |
-
)
|
270 |
-
del ckpt, csd
|
271 |
-
|
272 |
-
# DP mode
|
273 |
-
if cuda and RANK == -1 and torch.cuda.device_count() > 1:
|
274 |
-
LOGGER.warning(
|
275 |
-
"WARNING ⚠️ DP not recommended, use torch.distributed.run for best DDP Multi-GPU results.\n"
|
276 |
-
"See Multi-GPU Tutorial at https://github.com/ultralytics/yolov5/issues/475 to get started."
|
277 |
-
)
|
278 |
-
model = torch.nn.DataParallel(model)
|
279 |
-
|
280 |
-
# SyncBatchNorm
|
281 |
-
if opt.sync_bn and cuda and RANK != -1:
|
282 |
-
model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model).to(device)
|
283 |
-
LOGGER.info("Using SyncBatchNorm()")
|
284 |
-
|
285 |
-
# Trainloader
|
286 |
-
train_loader, dataset = create_dataloader(
|
287 |
-
train_path,
|
288 |
-
imgsz,
|
289 |
-
batch_size // WORLD_SIZE,
|
290 |
-
gs,
|
291 |
-
single_cls,
|
292 |
-
hyp=hyp,
|
293 |
-
augment=True,
|
294 |
-
cache=None if opt.cache == "val" else opt.cache,
|
295 |
-
rect=opt.rect,
|
296 |
-
rank=LOCAL_RANK,
|
297 |
-
workers=workers,
|
298 |
-
image_weights=opt.image_weights,
|
299 |
-
quad=opt.quad,
|
300 |
-
prefix=colorstr("train: "),
|
301 |
-
shuffle=True,
|
302 |
-
mask_downsample_ratio=mask_ratio,
|
303 |
-
overlap_mask=overlap,
|
304 |
-
)
|
305 |
-
labels = np.concatenate(dataset.labels, 0)
|
306 |
-
mlc = int(labels[:, 0].max()) # max label class
|
307 |
-
assert (
|
308 |
-
mlc < nc
|
309 |
-
), f"Label class {mlc} exceeds nc={nc} in {data}. Possible class labels are 0-{nc - 1}"
|
310 |
-
|
311 |
-
# Process 0
|
312 |
-
if RANK in {-1, 0}:
|
313 |
-
val_loader = create_dataloader(
|
314 |
-
val_path,
|
315 |
-
imgsz,
|
316 |
-
batch_size // WORLD_SIZE * 2,
|
317 |
-
gs,
|
318 |
-
single_cls,
|
319 |
-
hyp=hyp,
|
320 |
-
cache=None if noval else opt.cache,
|
321 |
-
rect=True,
|
322 |
-
rank=-1,
|
323 |
-
workers=workers * 2,
|
324 |
-
pad=0.5,
|
325 |
-
mask_downsample_ratio=mask_ratio,
|
326 |
-
overlap_mask=overlap,
|
327 |
-
prefix=colorstr("val: "),
|
328 |
-
)[0]
|
329 |
-
|
330 |
-
if not resume:
|
331 |
-
if not opt.noautoanchor:
|
332 |
-
check_anchors(
|
333 |
-
dataset, model=model, thr=hyp["anchor_t"], imgsz=imgsz
|
334 |
-
) # run AutoAnchor
|
335 |
-
model.half().float() # pre-reduce anchor precision
|
336 |
-
|
337 |
-
if plots:
|
338 |
-
plot_labels(labels, names, save_dir)
|
339 |
-
# callbacks.run('on_pretrain_routine_end', labels, names)
|
340 |
-
|
341 |
-
# DDP mode
|
342 |
-
if cuda and RANK != -1:
|
343 |
-
model = smart_DDP(model)
|
344 |
-
|
345 |
-
# Model attributes
|
346 |
-
nl = (
|
347 |
-
de_parallel(model).model[-1].nl
|
348 |
-
) # number of detection layers (to scale hyps)
|
349 |
-
hyp["box"] *= 3 / nl # scale to layers
|
350 |
-
hyp["cls"] *= nc / 80 * 3 / nl # scale to classes and layers
|
351 |
-
hyp["obj"] *= (imgsz / 640) ** 2 * 3 / nl # scale to image size and layers
|
352 |
-
hyp["label_smoothing"] = opt.label_smoothing
|
353 |
-
model.nc = nc # attach number of classes to model
|
354 |
-
model.hyp = hyp # attach hyperparameters to model
|
355 |
-
model.class_weights = (
|
356 |
-
labels_to_class_weights(dataset.labels, nc).to(device) * nc
|
357 |
-
) # attach class weights
|
358 |
-
model.names = names
|
359 |
-
|
360 |
-
# Start training
|
361 |
-
t0 = time.time()
|
362 |
-
nb = len(train_loader) # number of batches
|
363 |
-
nw = max(
|
364 |
-
round(hyp["warmup_epochs"] * nb), 100
|
365 |
-
) # number of warmup iterations, max(3 epochs, 100 iterations)
|
366 |
-
# nw = min(nw, (epochs - start_epoch) / 2 * nb) # limit warmup to < 1/2 of training
|
367 |
-
last_opt_step = -1
|
368 |
-
maps = np.zeros(nc) # mAP per class
|
369 |
-
results = (
|
370 |
-
0,
|
371 |
-
0,
|
372 |
-
0,
|
373 |
-
0,
|
374 |
-
0,
|
375 |
-
0,
|
376 |
-
0,
|
377 |
-
0,
|
378 |
-
0,
|
379 |
-
0,
|
380 |
-
0,
|
381 |
-
0,
|
382 |
-
) # P, R, [email protected], [email protected], val_loss(box, obj, cls)
|
383 |
-
scheduler.last_epoch = start_epoch - 1 # do not move
|
384 |
-
scaler = torch.cuda.amp.GradScaler(enabled=amp)
|
385 |
-
stopper, stop = EarlyStopping(patience=opt.patience), False
|
386 |
-
compute_loss = ComputeLoss(model, overlap=overlap) # init loss class
|
387 |
-
# callbacks.run('on_train_start')
|
388 |
-
LOGGER.info(
|
389 |
-
f"Image sizes {imgsz} train, {imgsz} val\n"
|
390 |
-
f"Using {train_loader.num_workers * WORLD_SIZE} dataloader workers\n"
|
391 |
-
f"Logging results to {colorstr('bold', save_dir)}\n"
|
392 |
-
f"Starting training for {epochs} epochs..."
|
393 |
-
)
|
394 |
-
for epoch in range(
|
395 |
-
start_epoch, epochs
|
396 |
-
): # epoch ------------------------------------------------------------------
|
397 |
-
# callbacks.run('on_train_epoch_start')
|
398 |
-
model.train()
|
399 |
-
|
400 |
-
# Update image weights (optional, single-GPU only)
|
401 |
-
if opt.image_weights:
|
402 |
-
cw = (
|
403 |
-
model.class_weights.cpu().numpy() * (1 - maps) ** 2 / nc
|
404 |
-
) # class weights
|
405 |
-
iw = labels_to_image_weights(
|
406 |
-
dataset.labels, nc=nc, class_weights=cw
|
407 |
-
) # image weights
|
408 |
-
dataset.indices = random.choices(
|
409 |
-
range(dataset.n), weights=iw, k=dataset.n
|
410 |
-
) # rand weighted idx
|
411 |
-
|
412 |
-
# Update mosaic border (optional)
|
413 |
-
# b = int(random.uniform(0.25 * imgsz, 0.75 * imgsz + gs) // gs * gs)
|
414 |
-
# dataset.mosaic_border = [b - imgsz, -b] # height, width borders
|
415 |
-
|
416 |
-
mloss = torch.zeros(4, device=device) # mean losses
|
417 |
-
if RANK != -1:
|
418 |
-
train_loader.sampler.set_epoch(epoch)
|
419 |
-
pbar = enumerate(train_loader)
|
420 |
-
LOGGER.info(
|
421 |
-
("\n" + "%11s" * 8)
|
422 |
-
% (
|
423 |
-
"Epoch",
|
424 |
-
"GPU_mem",
|
425 |
-
"box_loss",
|
426 |
-
"seg_loss",
|
427 |
-
"obj_loss",
|
428 |
-
"cls_loss",
|
429 |
-
"Instances",
|
430 |
-
"Size",
|
431 |
-
)
|
432 |
-
)
|
433 |
-
if RANK in {-1, 0}:
|
434 |
-
pbar = tqdm(
|
435 |
-
pbar, total=nb, bar_format=TQDM_BAR_FORMAT
|
436 |
-
) # progress bar
|
437 |
-
optimizer.zero_grad()
|
438 |
-
for i, (
|
439 |
-
imgs,
|
440 |
-
targets,
|
441 |
-
paths,
|
442 |
-
_,
|
443 |
-
masks,
|
444 |
-
) in (
|
445 |
-
pbar
|
446 |
-
): # batch ------------------------------------------------------
|
447 |
-
# callbacks.run('on_train_batch_start')
|
448 |
-
ni = (
|
449 |
-
i + nb * epoch
|
450 |
-
) # number integrated batches (since train start)
|
451 |
-
imgs = (
|
452 |
-
imgs.to(device, non_blocking=True).float() / 255
|
453 |
-
) # uint8 to float32, 0-255 to 0.0-1.0
|
454 |
-
|
455 |
-
# Warmup
|
456 |
-
if ni <= nw:
|
457 |
-
xi = [0, nw] # x interp
|
458 |
-
# compute_loss.gr = np.interp(ni, xi, [0.0, 1.0]) # iou loss ratio (obj_loss = 1.0 or iou)
|
459 |
-
accumulate = max(
|
460 |
-
1, np.interp(ni, xi, [1, nbs / batch_size]).round()
|
461 |
-
)
|
462 |
-
for j, x in enumerate(optimizer.param_groups):
|
463 |
-
# bias lr falls from 0.1 to lr0, all other lrs rise from 0.0 to lr0
|
464 |
-
x["lr"] = np.interp(
|
465 |
-
ni,
|
466 |
-
xi,
|
467 |
-
[
|
468 |
-
hyp["warmup_bias_lr"] if j == 0 else 0.0,
|
469 |
-
x["initial_lr"] * lf(epoch),
|
470 |
-
],
|
471 |
-
)
|
472 |
-
if "momentum" in x:
|
473 |
-
x["momentum"] = np.interp(
|
474 |
-
ni, xi, [hyp["warmup_momentum"], hyp["momentum"]]
|
475 |
-
)
|
476 |
-
|
477 |
-
# Multi-scale
|
478 |
-
if opt.multi_scale:
|
479 |
-
sz = (
|
480 |
-
random.randrange(imgsz * 0.5, imgsz * 1.5 + gs) // gs * gs
|
481 |
-
) # size
|
482 |
-
sf = sz / max(imgs.shape[2:]) # scale factor
|
483 |
-
if sf != 1:
|
484 |
-
ns = [
|
485 |
-
math.ceil(x * sf / gs) * gs for x in imgs.shape[2:]
|
486 |
-
] # new shape (stretched to gs-multiple)
|
487 |
-
imgs = nn.functional.interpolate(
|
488 |
-
imgs, size=ns, mode="bilinear", align_corners=False
|
489 |
-
)
|
490 |
-
|
491 |
-
# Forward
|
492 |
-
with torch.cuda.amp.autocast(amp):
|
493 |
-
pred = model(imgs) # forward
|
494 |
-
loss, loss_items = compute_loss(
|
495 |
-
pred, targets.to(device), masks=masks.to(device).float()
|
496 |
-
)
|
497 |
-
if RANK != -1:
|
498 |
-
loss *= WORLD_SIZE # gradient averaged between devices in DDP mode
|
499 |
-
if opt.quad:
|
500 |
-
loss *= 4.0
|
501 |
-
|
502 |
-
# Backward
|
503 |
-
scaler.scale(loss).backward()
|
504 |
-
|
505 |
-
# Optimize - https://pytorch.org/docs/master/notes/amp_examples.html
|
506 |
-
if ni - last_opt_step >= accumulate:
|
507 |
-
scaler.unscale_(optimizer) # unscale gradients
|
508 |
-
torch.nn.utils.clip_grad_norm_(
|
509 |
-
model.parameters(), max_norm=10.0
|
510 |
-
) # clip gradients
|
511 |
-
scaler.step(optimizer) # optimizer.step
|
512 |
-
scaler.update()
|
513 |
-
optimizer.zero_grad()
|
514 |
-
if ema:
|
515 |
-
ema.update(model)
|
516 |
-
last_opt_step = ni
|
517 |
-
|
518 |
-
# Log
|
519 |
-
if RANK in {-1, 0}:
|
520 |
-
mloss = (mloss * i + loss_items) / (
|
521 |
-
i + 1
|
522 |
-
) # update mean losses
|
523 |
-
mem = f"{torch.cuda.memory_reserved() / 1E9 if torch.cuda.is_available() else 0:.3g}G" # (GB)
|
524 |
-
pbar.set_description(
|
525 |
-
("%11s" * 2 + "%11.4g" * 6)
|
526 |
-
% (
|
527 |
-
f"{epoch}/{epochs - 1}",
|
528 |
-
mem,
|
529 |
-
*mloss,
|
530 |
-
targets.shape[0],
|
531 |
-
imgs.shape[-1],
|
532 |
-
)
|
533 |
-
)
|
534 |
-
# callbacks.run('on_train_batch_end', model, ni, imgs, targets, paths)
|
535 |
-
# if callbacks.stop_training:
|
536 |
-
# return
|
537 |
-
|
538 |
-
# Mosaic plots
|
539 |
-
if plots:
|
540 |
-
if ni < 3:
|
541 |
-
plot_images_and_masks(
|
542 |
-
imgs,
|
543 |
-
targets,
|
544 |
-
masks,
|
545 |
-
paths,
|
546 |
-
save_dir / f"train_batch{ni}.jpg",
|
547 |
-
)
|
548 |
-
if ni == 10:
|
549 |
-
files = sorted(save_dir.glob("train*.jpg"))
|
550 |
-
logger.log_images(files, "Mosaics", epoch)
|
551 |
-
# end batch ------------------------------------------------------------------------------------------------
|
552 |
-
|
553 |
-
# Scheduler
|
554 |
-
lr = [x["lr"] for x in optimizer.param_groups] # for loggers
|
555 |
-
scheduler.step()
|
556 |
-
|
557 |
-
if RANK in {-1, 0}:
|
558 |
-
# mAP
|
559 |
-
# callbacks.run('on_train_epoch_end', epoch=epoch)
|
560 |
-
ema.update_attr(
|
561 |
-
model,
|
562 |
-
include=[
|
563 |
-
"yaml",
|
564 |
-
"nc",
|
565 |
-
"hyp",
|
566 |
-
"names",
|
567 |
-
"stride",
|
568 |
-
"class_weights",
|
569 |
-
],
|
570 |
-
)
|
571 |
-
final_epoch = (epoch + 1 == epochs) or stopper.possible_stop
|
572 |
-
if not noval or final_epoch: # Calculate mAP
|
573 |
-
results, maps, _ = validate.run(
|
574 |
-
data_dict,
|
575 |
-
batch_size=batch_size // WORLD_SIZE * 2,
|
576 |
-
imgsz=imgsz,
|
577 |
-
half=amp,
|
578 |
-
model=ema.ema,
|
579 |
-
single_cls=single_cls,
|
580 |
-
dataloader=val_loader,
|
581 |
-
save_dir=save_dir,
|
582 |
-
plots=False,
|
583 |
-
callbacks=callbacks,
|
584 |
-
compute_loss=compute_loss,
|
585 |
-
mask_downsample_ratio=mask_ratio,
|
586 |
-
overlap=overlap,
|
587 |
-
)
|
588 |
-
|
589 |
-
# Update best mAP
|
590 |
-
fi = fitness(
|
591 |
-
np.array(results).reshape(1, -1)
|
592 |
-
) # weighted combination of [P, R, [email protected], [email protected]]
|
593 |
-
stop = stopper(epoch=epoch, fitness=fi) # early stop check
|
594 |
-
if fi > best_fitness:
|
595 |
-
best_fitness = fi
|
596 |
-
log_vals = list(mloss) + list(results) + lr
|
597 |
-
# callbacks.run('on_fit_epoch_end', log_vals, epoch, best_fitness, fi)
|
598 |
-
# Log val metrics and media
|
599 |
-
metrics_dict = dict(zip(KEYS, log_vals))
|
600 |
-
logger.log_metrics(metrics_dict, epoch)
|
601 |
-
|
602 |
-
# Save model
|
603 |
-
if (not nosave) or (final_epoch and not evolve): # if save
|
604 |
-
ckpt = {
|
605 |
-
"epoch": epoch,
|
606 |
-
"best_fitness": best_fitness,
|
607 |
-
"model": deepcopy(de_parallel(model)).half(),
|
608 |
-
"ema": deepcopy(ema.ema).half(),
|
609 |
-
"updates": ema.updates,
|
610 |
-
"optimizer": optimizer.state_dict(),
|
611 |
-
"opt": vars(opt),
|
612 |
-
"git": GIT_INFO, # {remote, branch, commit} if a git repo
|
613 |
-
"date": datetime.now().isoformat(),
|
614 |
-
}
|
615 |
-
|
616 |
-
# Save last, best and delete
|
617 |
-
torch.save(ckpt, last)
|
618 |
-
if best_fitness == fi:
|
619 |
-
torch.save(ckpt, best)
|
620 |
-
if opt.save_period > 0 and epoch % opt.save_period == 0:
|
621 |
-
torch.save(ckpt, w / f"epoch{epoch}.pt")
|
622 |
-
logger.log_model(w / f"epoch{epoch}.pt")
|
623 |
-
del ckpt
|
624 |
-
# callbacks.run('on_model_save', last, epoch, final_epoch, best_fitness, fi)
|
625 |
-
|
626 |
-
# EarlyStopping
|
627 |
-
if RANK != -1: # if DDP training
|
628 |
-
broadcast_list = [stop if RANK == 0 else None]
|
629 |
-
dist.broadcast_object_list(
|
630 |
-
broadcast_list, 0
|
631 |
-
) # broadcast 'stop' to all ranks
|
632 |
-
if RANK != 0:
|
633 |
-
stop = broadcast_list[0]
|
634 |
-
if stop:
|
635 |
-
break # must break all DDP ranks
|
636 |
-
|
637 |
-
# end epoch ----------------------------------------------------------------------------------------------------
|
638 |
-
# end training -----------------------------------------------------------------------------------------------------
|
639 |
-
if RANK in {-1, 0}:
|
640 |
-
LOGGER.info(
|
641 |
-
f"\n{epoch - start_epoch + 1} epochs completed in {(time.time() - t0) / 3600:.3f} hours."
|
642 |
-
)
|
643 |
-
for f in last, best:
|
644 |
-
if f.exists():
|
645 |
-
strip_optimizer(f) # strip optimizers
|
646 |
-
if f is best:
|
647 |
-
LOGGER.info(f"\nValidating {f}...")
|
648 |
-
results, _, _ = validate.run(
|
649 |
-
data_dict,
|
650 |
-
batch_size=batch_size // WORLD_SIZE * 2,
|
651 |
-
imgsz=imgsz,
|
652 |
-
model=attempt_load(f, device).half(),
|
653 |
-
iou_thres=0.65
|
654 |
-
if is_coco
|
655 |
-
else 0.60, # best pycocotools at iou 0.65
|
656 |
-
single_cls=single_cls,
|
657 |
-
dataloader=val_loader,
|
658 |
-
save_dir=save_dir,
|
659 |
-
save_json=is_coco,
|
660 |
-
verbose=True,
|
661 |
-
plots=plots,
|
662 |
-
callbacks=callbacks,
|
663 |
-
compute_loss=compute_loss,
|
664 |
-
mask_downsample_ratio=mask_ratio,
|
665 |
-
overlap=overlap,
|
666 |
-
) # val best model with plots
|
667 |
-
if is_coco:
|
668 |
-
# callbacks.run('on_fit_epoch_end', list(mloss) + list(results) + lr, epoch, best_fitness, fi)
|
669 |
-
metrics_dict = dict(
|
670 |
-
zip(KEYS, list(mloss) + list(results) + lr)
|
671 |
-
)
|
672 |
-
logger.log_metrics(metrics_dict, epoch)
|
673 |
-
|
674 |
-
# callbacks.run('on_train_end', last, best, epoch, results)
|
675 |
-
# on train end callback using genericLogger
|
676 |
-
logger.log_metrics(dict(zip(KEYS[4:16], results)), epochs)
|
677 |
-
if not opt.evolve:
|
678 |
-
logger.log_model(best, epoch)
|
679 |
-
if plots:
|
680 |
-
plot_results_with_masks(
|
681 |
-
file=save_dir / "results.csv"
|
682 |
-
) # save results.png
|
683 |
-
files = [
|
684 |
-
"results.png",
|
685 |
-
"confusion_matrix.png",
|
686 |
-
*(f"{x}_curve.png" for x in ("F1", "PR", "P", "R")),
|
687 |
-
]
|
688 |
-
files = [
|
689 |
-
(save_dir / f) for f in files if (save_dir / f).exists()
|
690 |
-
] # filter
|
691 |
-
LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}")
|
692 |
-
logger.log_images(files, "Results", epoch + 1)
|
693 |
-
logger.log_images(
|
694 |
-
sorted(save_dir.glob("val*.jpg")), "Validation", epoch + 1
|
695 |
-
)
|
696 |
-
torch.cuda.empty_cache()
|
697 |
-
return results
|
698 |
-
|
699 |
-
|
700 |
-
def parse_opt(known=False):
|
701 |
-
parser = argparse.ArgumentParser()
|
702 |
-
parser.add_argument(
|
703 |
-
"--weights",
|
704 |
-
type=str,
|
705 |
-
default=ROOT / "yolov5s-seg.pt",
|
706 |
-
help="initial weights path",
|
707 |
-
)
|
708 |
-
parser.add_argument("--cfg", type=str, default="", help="model.yaml path")
|
709 |
-
parser.add_argument(
|
710 |
-
"--data",
|
711 |
-
type=str,
|
712 |
-
default=ROOT / "data/coco128-seg.yaml",
|
713 |
-
help="dataset.yaml path",
|
714 |
-
)
|
715 |
-
parser.add_argument(
|
716 |
-
"--hyp",
|
717 |
-
type=str,
|
718 |
-
default=ROOT / "data/hyps/hyp.scratch-low.yaml",
|
719 |
-
help="hyperparameters path",
|
720 |
-
)
|
721 |
-
parser.add_argument(
|
722 |
-
"--epochs", type=int, default=100, help="total training epochs"
|
723 |
-
)
|
724 |
-
parser.add_argument(
|
725 |
-
"--batch-size",
|
726 |
-
type=int,
|
727 |
-
default=16,
|
728 |
-
help="total batch size for all GPUs, -1 for autobatch",
|
729 |
-
)
|
730 |
-
parser.add_argument(
|
731 |
-
"--imgsz",
|
732 |
-
"--img",
|
733 |
-
"--img-size",
|
734 |
-
type=int,
|
735 |
-
default=640,
|
736 |
-
help="train, val image size (pixels)",
|
737 |
-
)
|
738 |
-
parser.add_argument(
|
739 |
-
"--rect", action="store_true", help="rectangular training"
|
740 |
-
)
|
741 |
-
parser.add_argument(
|
742 |
-
"--resume",
|
743 |
-
nargs="?",
|
744 |
-
const=True,
|
745 |
-
default=False,
|
746 |
-
help="resume most recent training",
|
747 |
-
)
|
748 |
-
parser.add_argument(
|
749 |
-
"--nosave", action="store_true", help="only save final checkpoint"
|
750 |
-
)
|
751 |
-
parser.add_argument(
|
752 |
-
"--noval", action="store_true", help="only validate final epoch"
|
753 |
-
)
|
754 |
-
parser.add_argument(
|
755 |
-
"--noautoanchor", action="store_true", help="disable AutoAnchor"
|
756 |
-
)
|
757 |
-
parser.add_argument(
|
758 |
-
"--noplots", action="store_true", help="save no plot files"
|
759 |
-
)
|
760 |
-
parser.add_argument(
|
761 |
-
"--evolve",
|
762 |
-
type=int,
|
763 |
-
nargs="?",
|
764 |
-
const=300,
|
765 |
-
help="evolve hyperparameters for x generations",
|
766 |
-
)
|
767 |
-
parser.add_argument("--bucket", type=str, default="", help="gsutil bucket")
|
768 |
-
parser.add_argument(
|
769 |
-
"--cache",
|
770 |
-
type=str,
|
771 |
-
nargs="?",
|
772 |
-
const="ram",
|
773 |
-
help="image --cache ram/disk",
|
774 |
-
)
|
775 |
-
parser.add_argument(
|
776 |
-
"--image-weights",
|
777 |
-
action="store_true",
|
778 |
-
help="use weighted image selection for training",
|
779 |
-
)
|
780 |
-
parser.add_argument(
|
781 |
-
"--device", default="", help="cuda device, i.e. 0 or 0,1,2,3 or cpu"
|
782 |
-
)
|
783 |
-
parser.add_argument(
|
784 |
-
"--multi-scale", action="store_true", help="vary img-size +/- 50%%"
|
785 |
-
)
|
786 |
-
parser.add_argument(
|
787 |
-
"--single-cls",
|
788 |
-
action="store_true",
|
789 |
-
help="train multi-class data as single-class",
|
790 |
-
)
|
791 |
-
parser.add_argument(
|
792 |
-
"--optimizer",
|
793 |
-
type=str,
|
794 |
-
choices=["SGD", "Adam", "AdamW"],
|
795 |
-
default="SGD",
|
796 |
-
help="optimizer",
|
797 |
-
)
|
798 |
-
parser.add_argument(
|
799 |
-
"--sync-bn",
|
800 |
-
action="store_true",
|
801 |
-
help="use SyncBatchNorm, only available in DDP mode",
|
802 |
-
)
|
803 |
-
parser.add_argument(
|
804 |
-
"--workers",
|
805 |
-
type=int,
|
806 |
-
default=8,
|
807 |
-
help="max dataloader workers (per RANK in DDP mode)",
|
808 |
-
)
|
809 |
-
parser.add_argument(
|
810 |
-
"--project",
|
811 |
-
default=ROOT / "runs/train-seg",
|
812 |
-
help="save to project/name",
|
813 |
-
)
|
814 |
-
parser.add_argument("--name", default="exp", help="save to project/name")
|
815 |
-
parser.add_argument(
|
816 |
-
"--exist-ok",
|
817 |
-
action="store_true",
|
818 |
-
help="existing project/name ok, do not increment",
|
819 |
-
)
|
820 |
-
parser.add_argument("--quad", action="store_true", help="quad dataloader")
|
821 |
-
parser.add_argument(
|
822 |
-
"--cos-lr", action="store_true", help="cosine LR scheduler"
|
823 |
-
)
|
824 |
-
parser.add_argument(
|
825 |
-
"--label-smoothing",
|
826 |
-
type=float,
|
827 |
-
default=0.0,
|
828 |
-
help="Label smoothing epsilon",
|
829 |
-
)
|
830 |
-
parser.add_argument(
|
831 |
-
"--patience",
|
832 |
-
type=int,
|
833 |
-
default=100,
|
834 |
-
help="EarlyStopping patience (epochs without improvement)",
|
835 |
-
)
|
836 |
-
parser.add_argument(
|
837 |
-
"--freeze",
|
838 |
-
nargs="+",
|
839 |
-
type=int,
|
840 |
-
default=[0],
|
841 |
-
help="Freeze layers: backbone=10, first3=0 1 2",
|
842 |
-
)
|
843 |
-
parser.add_argument(
|
844 |
-
"--save-period",
|
845 |
-
type=int,
|
846 |
-
default=-1,
|
847 |
-
help="Save checkpoint every x epochs (disabled if < 1)",
|
848 |
-
)
|
849 |
-
parser.add_argument(
|
850 |
-
"--seed", type=int, default=0, help="Global training seed"
|
851 |
-
)
|
852 |
-
parser.add_argument(
|
853 |
-
"--local_rank",
|
854 |
-
type=int,
|
855 |
-
default=-1,
|
856 |
-
help="Automatic DDP Multi-GPU argument, do not modify",
|
857 |
-
)
|
858 |
-
|
859 |
-
# Instance Segmentation Args
|
860 |
-
parser.add_argument(
|
861 |
-
"--mask-ratio",
|
862 |
-
type=int,
|
863 |
-
default=4,
|
864 |
-
help="Downsample the truth masks to saving memory",
|
865 |
-
)
|
866 |
-
parser.add_argument(
|
867 |
-
"--no-overlap",
|
868 |
-
action="store_true",
|
869 |
-
help="Overlap masks train faster at slightly less mAP",
|
870 |
-
)
|
871 |
-
|
872 |
-
return parser.parse_known_args()[0] if known else parser.parse_args()
|
873 |
-
|
874 |
-
|
875 |
-
def main(opt, callbacks=Callbacks()):
|
876 |
-
# Checks
|
877 |
-
if RANK in {-1, 0}:
|
878 |
-
print_args(vars(opt))
|
879 |
-
check_git_status()
|
880 |
-
check_requirements()
|
881 |
-
|
882 |
-
# Resume
|
883 |
-
if (
|
884 |
-
opt.resume and not opt.evolve
|
885 |
-
): # resume from specified or most recent last.pt
|
886 |
-
last = Path(
|
887 |
-
check_file(opt.resume)
|
888 |
-
if isinstance(opt.resume, str)
|
889 |
-
else get_latest_run()
|
890 |
-
)
|
891 |
-
opt_yaml = last.parent.parent / "opt.yaml" # train options yaml
|
892 |
-
opt_data = opt.data # original dataset
|
893 |
-
if opt_yaml.is_file():
|
894 |
-
with open(opt_yaml, errors="ignore") as f:
|
895 |
-
d = yaml.safe_load(f)
|
896 |
-
else:
|
897 |
-
d = torch.load(last, map_location="cpu")["opt"]
|
898 |
-
opt = argparse.Namespace(**d) # replace
|
899 |
-
opt.cfg, opt.weights, opt.resume = "", str(last), True # reinstate
|
900 |
-
if is_url(opt_data):
|
901 |
-
opt.data = check_file(opt_data) # avoid HUB resume auth timeout
|
902 |
-
else:
|
903 |
-
opt.data, opt.cfg, opt.hyp, opt.weights, opt.project = (
|
904 |
-
check_file(opt.data),
|
905 |
-
check_yaml(opt.cfg),
|
906 |
-
check_yaml(opt.hyp),
|
907 |
-
str(opt.weights),
|
908 |
-
str(opt.project),
|
909 |
-
) # checks
|
910 |
-
assert len(opt.cfg) or len(
|
911 |
-
opt.weights
|
912 |
-
), "either --cfg or --weights must be specified"
|
913 |
-
if opt.evolve:
|
914 |
-
if opt.project == str(
|
915 |
-
ROOT / "runs/train"
|
916 |
-
): # if default project name, rename to runs/evolve
|
917 |
-
opt.project = str(ROOT / "runs/evolve")
|
918 |
-
opt.exist_ok, opt.resume = (
|
919 |
-
opt.resume,
|
920 |
-
False,
|
921 |
-
) # pass resume to exist_ok and disable resume
|
922 |
-
if opt.name == "cfg":
|
923 |
-
opt.name = Path(opt.cfg).stem # use model.yaml as name
|
924 |
-
opt.save_dir = str(
|
925 |
-
increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)
|
926 |
-
)
|
927 |
-
|
928 |
-
# DDP mode
|
929 |
-
device = select_device(opt.device, batch_size=opt.batch_size)
|
930 |
-
if LOCAL_RANK != -1:
|
931 |
-
msg = "is not compatible with YOLOv5 Multi-GPU DDP training"
|
932 |
-
assert not opt.image_weights, f"--image-weights {msg}"
|
933 |
-
assert not opt.evolve, f"--evolve {msg}"
|
934 |
-
assert (
|
935 |
-
opt.batch_size != -1
|
936 |
-
), f"AutoBatch with --batch-size -1 {msg}, please pass a valid --batch-size"
|
937 |
-
assert (
|
938 |
-
opt.batch_size % WORLD_SIZE == 0
|
939 |
-
), f"--batch-size {opt.batch_size} must be multiple of WORLD_SIZE"
|
940 |
-
assert (
|
941 |
-
torch.cuda.device_count() > LOCAL_RANK
|
942 |
-
), "insufficient CUDA devices for DDP command"
|
943 |
-
torch.cuda.set_device(LOCAL_RANK)
|
944 |
-
device = torch.device("cuda", LOCAL_RANK)
|
945 |
-
dist.init_process_group(
|
946 |
-
backend="nccl" if dist.is_nccl_available() else "gloo"
|
947 |
-
)
|
948 |
-
|
949 |
-
# Train
|
950 |
-
if not opt.evolve:
|
951 |
-
train(opt.hyp, opt, device, callbacks)
|
952 |
-
|
953 |
-
# Evolve hyperparameters (optional)
|
954 |
-
else:
|
955 |
-
# Hyperparameter evolution metadata (mutation scale 0-1, lower_limit, upper_limit)
|
956 |
-
meta = {
|
957 |
-
"lr0": (
|
958 |
-
1,
|
959 |
-
1e-5,
|
960 |
-
1e-1,
|
961 |
-
), # initial learning rate (SGD=1E-2, Adam=1E-3)
|
962 |
-
"lrf": (
|
963 |
-
1,
|
964 |
-
0.01,
|
965 |
-
1.0,
|
966 |
-
), # final OneCycleLR learning rate (lr0 * lrf)
|
967 |
-
"momentum": (0.3, 0.6, 0.98), # SGD momentum/Adam beta1
|
968 |
-
"weight_decay": (1, 0.0, 0.001), # optimizer weight decay
|
969 |
-
"warmup_epochs": (1, 0.0, 5.0), # warmup epochs (fractions ok)
|
970 |
-
"warmup_momentum": (1, 0.0, 0.95), # warmup initial momentum
|
971 |
-
"warmup_bias_lr": (1, 0.0, 0.2), # warmup initial bias lr
|
972 |
-
"box": (1, 0.02, 0.2), # box loss gain
|
973 |
-
"cls": (1, 0.2, 4.0), # cls loss gain
|
974 |
-
"cls_pw": (1, 0.5, 2.0), # cls BCELoss positive_weight
|
975 |
-
"obj": (1, 0.2, 4.0), # obj loss gain (scale with pixels)
|
976 |
-
"obj_pw": (1, 0.5, 2.0), # obj BCELoss positive_weight
|
977 |
-
"iou_t": (0, 0.1, 0.7), # IoU training threshold
|
978 |
-
"anchor_t": (1, 2.0, 8.0), # anchor-multiple threshold
|
979 |
-
"anchors": (2, 2.0, 10.0), # anchors per output grid (0 to ignore)
|
980 |
-
"fl_gamma": (
|
981 |
-
0,
|
982 |
-
0.0,
|
983 |
-
2.0,
|
984 |
-
), # focal loss gamma (efficientDet default gamma=1.5)
|
985 |
-
"hsv_h": (1, 0.0, 0.1), # image HSV-Hue augmentation (fraction)
|
986 |
-
"hsv_s": (
|
987 |
-
1,
|
988 |
-
0.0,
|
989 |
-
0.9,
|
990 |
-
), # image HSV-Saturation augmentation (fraction)
|
991 |
-
"hsv_v": (1, 0.0, 0.9), # image HSV-Value augmentation (fraction)
|
992 |
-
"degrees": (1, 0.0, 45.0), # image rotation (+/- deg)
|
993 |
-
"translate": (1, 0.0, 0.9), # image translation (+/- fraction)
|
994 |
-
"scale": (1, 0.0, 0.9), # image scale (+/- gain)
|
995 |
-
"shear": (1, 0.0, 10.0), # image shear (+/- deg)
|
996 |
-
"perspective": (
|
997 |
-
0,
|
998 |
-
0.0,
|
999 |
-
0.001,
|
1000 |
-
), # image perspective (+/- fraction), range 0-0.001
|
1001 |
-
"flipud": (1, 0.0, 1.0), # image flip up-down (probability)
|
1002 |
-
"fliplr": (0, 0.0, 1.0), # image flip left-right (probability)
|
1003 |
-
"mosaic": (1, 0.0, 1.0), # image mixup (probability)
|
1004 |
-
"mixup": (1, 0.0, 1.0), # image mixup (probability)
|
1005 |
-
"copy_paste": (1, 0.0, 1.0),
|
1006 |
-
} # segment copy-paste (probability)
|
1007 |
-
|
1008 |
-
with open(opt.hyp, errors="ignore") as f:
|
1009 |
-
hyp = yaml.safe_load(f) # load hyps dict
|
1010 |
-
if "anchors" not in hyp: # anchors commented in hyp.yaml
|
1011 |
-
hyp["anchors"] = 3
|
1012 |
-
if opt.noautoanchor:
|
1013 |
-
del hyp["anchors"], meta["anchors"]
|
1014 |
-
opt.noval, opt.nosave, save_dir = (
|
1015 |
-
True,
|
1016 |
-
True,
|
1017 |
-
Path(opt.save_dir),
|
1018 |
-
) # only val/save final epoch
|
1019 |
-
# ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices
|
1020 |
-
evolve_yaml, evolve_csv = (
|
1021 |
-
save_dir / "hyp_evolve.yaml",
|
1022 |
-
save_dir / "evolve.csv",
|
1023 |
-
)
|
1024 |
-
if opt.bucket:
|
1025 |
-
os.system(
|
1026 |
-
f"gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}"
|
1027 |
-
) # download evolve.csv if exists
|
1028 |
-
|
1029 |
-
for _ in range(opt.evolve): # generations to evolve
|
1030 |
-
if (
|
1031 |
-
evolve_csv.exists()
|
1032 |
-
): # if evolve.csv exists: select best hyps and mutate
|
1033 |
-
# Select parent(s)
|
1034 |
-
parent = (
|
1035 |
-
"single" # parent selection method: 'single' or 'weighted'
|
1036 |
-
)
|
1037 |
-
x = np.loadtxt(evolve_csv, ndmin=2, delimiter=",", skiprows=1)
|
1038 |
-
n = min(5, len(x)) # number of previous results to consider
|
1039 |
-
x = x[np.argsort(-fitness(x))][:n] # top n mutations
|
1040 |
-
w = fitness(x) - fitness(x).min() + 1e-6 # weights (sum > 0)
|
1041 |
-
if parent == "single" or len(x) == 1:
|
1042 |
-
# x = x[random.randint(0, n - 1)] # random selection
|
1043 |
-
x = x[
|
1044 |
-
random.choices(range(n), weights=w)[0]
|
1045 |
-
] # weighted selection
|
1046 |
-
elif parent == "weighted":
|
1047 |
-
x = (x * w.reshape(n, 1)).sum(
|
1048 |
-
0
|
1049 |
-
) / w.sum() # weighted combination
|
1050 |
-
|
1051 |
-
# Mutate
|
1052 |
-
mp, s = 0.8, 0.2 # mutation probability, sigma
|
1053 |
-
npr = np.random
|
1054 |
-
npr.seed(int(time.time()))
|
1055 |
-
g = np.array([meta[k][0] for k in hyp.keys()]) # gains 0-1
|
1056 |
-
ng = len(meta)
|
1057 |
-
v = np.ones(ng)
|
1058 |
-
while all(
|
1059 |
-
v == 1
|
1060 |
-
): # mutate until a change occurs (prevent duplicates)
|
1061 |
-
v = (
|
1062 |
-
g
|
1063 |
-
* (npr.random(ng) < mp)
|
1064 |
-
* npr.randn(ng)
|
1065 |
-
* npr.random()
|
1066 |
-
* s
|
1067 |
-
+ 1
|
1068 |
-
).clip(0.3, 3.0)
|
1069 |
-
for i, k in enumerate(hyp.keys()): # plt.hist(v.ravel(), 300)
|
1070 |
-
hyp[k] = float(x[i + 7] * v[i]) # mutate
|
1071 |
-
|
1072 |
-
# Constrain to limits
|
1073 |
-
for k, v in meta.items():
|
1074 |
-
hyp[k] = max(hyp[k], v[1]) # lower limit
|
1075 |
-
hyp[k] = min(hyp[k], v[2]) # upper limit
|
1076 |
-
hyp[k] = round(hyp[k], 5) # significant digits
|
1077 |
-
|
1078 |
-
# Train mutation
|
1079 |
-
results = train(hyp.copy(), opt, device, callbacks)
|
1080 |
-
callbacks = Callbacks()
|
1081 |
-
# Write mutation results
|
1082 |
-
print_mutation(KEYS, results, hyp.copy(), save_dir, opt.bucket)
|
1083 |
-
|
1084 |
-
# Plot results
|
1085 |
-
plot_evolve(evolve_csv)
|
1086 |
-
LOGGER.info(
|
1087 |
-
f"Hyperparameter evolution finished {opt.evolve} generations\n"
|
1088 |
-
f"Results saved to {colorstr('bold', save_dir)}\n"
|
1089 |
-
f"Usage example: $ python train.py --hyp {evolve_yaml}"
|
1090 |
-
)
|
1091 |
-
|
1092 |
-
|
1093 |
-
def run(**kwargs):
|
1094 |
-
# Usage: import train; train.run(data='coco128.yaml', imgsz=320, weights='yolov5m.pt')
|
1095 |
-
opt = parse_opt(True)
|
1096 |
-
for k, v in kwargs.items():
|
1097 |
-
setattr(opt, k, v)
|
1098 |
-
main(opt)
|
1099 |
-
return opt
|
1100 |
-
|
1101 |
-
|
1102 |
-
if __name__ == "__main__":
|
1103 |
-
opt = parse_opt()
|
1104 |
-
main(opt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AchyuthGamer/OpenGPT-Chat-UI/src/lib/server/auth.ts
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
import { Issuer, BaseClient, type UserinfoResponse, TokenSet } from "openid-client";
|
2 |
-
import { addHours, addYears } from "date-fns";
|
3 |
-
import {
|
4 |
-
COOKIE_NAME,
|
5 |
-
OPENID_CLIENT_ID,
|
6 |
-
OPENID_CLIENT_SECRET,
|
7 |
-
OPENID_PROVIDER_URL,
|
8 |
-
OPENID_SCOPES,
|
9 |
-
} from "$env/static/private";
|
10 |
-
import { sha256 } from "$lib/utils/sha256";
|
11 |
-
import { z } from "zod";
|
12 |
-
import { dev } from "$app/environment";
|
13 |
-
import type { Cookies } from "@sveltejs/kit";
|
14 |
-
|
15 |
-
export interface OIDCSettings {
|
16 |
-
redirectURI: string;
|
17 |
-
}
|
18 |
-
|
19 |
-
export interface OIDCUserInfo {
|
20 |
-
token: TokenSet;
|
21 |
-
userData: UserinfoResponse;
|
22 |
-
}
|
23 |
-
|
24 |
-
export const requiresUser = !!OPENID_CLIENT_ID && !!OPENID_CLIENT_SECRET;
|
25 |
-
|
26 |
-
export function refreshSessionCookie(cookies: Cookies, sessionId: string) {
|
27 |
-
cookies.set(COOKIE_NAME, sessionId, {
|
28 |
-
path: "/",
|
29 |
-
// So that it works inside the space's iframe
|
30 |
-
sameSite: dev ? "lax" : "none",
|
31 |
-
secure: !dev,
|
32 |
-
httpOnly: true,
|
33 |
-
expires: addYears(new Date(), 1),
|
34 |
-
});
|
35 |
-
}
|
36 |
-
|
37 |
-
export const authCondition = (locals: App.Locals) => {
|
38 |
-
return locals.user
|
39 |
-
? { userId: locals.user._id }
|
40 |
-
: { sessionId: locals.sessionId, userId: { $exists: false } };
|
41 |
-
};
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Generates a CSRF token using the user sessionId. Note that we don't need a secret because sessionId is enough.
|
45 |
-
*/
|
46 |
-
export async function generateCsrfToken(sessionId: string, redirectUrl: string): Promise<string> {
|
47 |
-
const data = {
|
48 |
-
expiration: addHours(new Date(), 1).getTime(),
|
49 |
-
redirectUrl,
|
50 |
-
};
|
51 |
-
|
52 |
-
return Buffer.from(
|
53 |
-
JSON.stringify({
|
54 |
-
data,
|
55 |
-
signature: await sha256(JSON.stringify(data) + "##" + sessionId),
|
56 |
-
})
|
57 |
-
).toString("base64");
|
58 |
-
}
|
59 |
-
|
60 |
-
async function getOIDCClient(settings: OIDCSettings): Promise<BaseClient> {
|
61 |
-
const issuer = await Issuer.discover(OPENID_PROVIDER_URL);
|
62 |
-
return new issuer.Client({
|
63 |
-
client_id: OPENID_CLIENT_ID,
|
64 |
-
client_secret: OPENID_CLIENT_SECRET,
|
65 |
-
redirect_uris: [settings.redirectURI],
|
66 |
-
response_types: ["code"],
|
67 |
-
});
|
68 |
-
}
|
69 |
-
|
70 |
-
export async function getOIDCAuthorizationUrl(
|
71 |
-
settings: OIDCSettings,
|
72 |
-
params: { sessionId: string }
|
73 |
-
): Promise<string> {
|
74 |
-
const client = await getOIDCClient(settings);
|
75 |
-
const csrfToken = await generateCsrfToken(params.sessionId, settings.redirectURI);
|
76 |
-
const url = client.authorizationUrl({
|
77 |
-
scope: OPENID_SCOPES,
|
78 |
-
state: csrfToken,
|
79 |
-
});
|
80 |
-
|
81 |
-
return url;
|
82 |
-
}
|
83 |
-
|
84 |
-
export async function getOIDCUserData(settings: OIDCSettings, code: string): Promise<OIDCUserInfo> {
|
85 |
-
const client = await getOIDCClient(settings);
|
86 |
-
const token = await client.callback(settings.redirectURI, { code });
|
87 |
-
const userData = await client.userinfo(token);
|
88 |
-
|
89 |
-
return { token, userData };
|
90 |
-
}
|
91 |
-
|
92 |
-
export async function validateAndParseCsrfToken(
|
93 |
-
token: string,
|
94 |
-
sessionId: string
|
95 |
-
): Promise<{
|
96 |
-
/** This is the redirect url that was passed to the OIDC provider */
|
97 |
-
redirectUrl: string;
|
98 |
-
} | null> {
|
99 |
-
try {
|
100 |
-
const { data, signature } = z
|
101 |
-
.object({
|
102 |
-
data: z.object({
|
103 |
-
expiration: z.number().int(),
|
104 |
-
redirectUrl: z.string().url(),
|
105 |
-
}),
|
106 |
-
signature: z.string().length(64),
|
107 |
-
})
|
108 |
-
.parse(JSON.parse(token));
|
109 |
-
const reconstructSign = await sha256(JSON.stringify(data) + "##" + sessionId);
|
110 |
-
|
111 |
-
if (data.expiration > Date.now() && signature === reconstructSign) {
|
112 |
-
return { redirectUrl: data.redirectUrl };
|
113 |
-
}
|
114 |
-
} catch (e) {
|
115 |
-
console.error(e);
|
116 |
-
}
|
117 |
-
return null;
|
118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AchyuthGamer/OpenGPT/g4f/Provider/deprecated/Wuguokai.py
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
from __future__ import annotations
|
2 |
-
|
3 |
-
import random
|
4 |
-
|
5 |
-
import requests
|
6 |
-
|
7 |
-
from ...typing import Any, CreateResult
|
8 |
-
from ..base_provider import BaseProvider, format_prompt
|
9 |
-
|
10 |
-
|
11 |
-
class Wuguokai(BaseProvider):
|
12 |
-
url = 'https://chat.wuguokai.xyz'
|
13 |
-
supports_gpt_35_turbo = True
|
14 |
-
working = False
|
15 |
-
|
16 |
-
@staticmethod
|
17 |
-
def create_completion(
|
18 |
-
model: str,
|
19 |
-
messages: list[dict[str, str]],
|
20 |
-
stream: bool,
|
21 |
-
**kwargs: Any,
|
22 |
-
) -> CreateResult:
|
23 |
-
headers = {
|
24 |
-
'authority': 'ai-api.wuguokai.xyz',
|
25 |
-
'accept': 'application/json, text/plain, */*',
|
26 |
-
'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
|
27 |
-
'content-type': 'application/json',
|
28 |
-
'origin': 'https://chat.wuguokai.xyz',
|
29 |
-
'referer': 'https://chat.wuguokai.xyz/',
|
30 |
-
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
31 |
-
'sec-ch-ua-mobile': '?0',
|
32 |
-
'sec-ch-ua-platform': '"Windows"',
|
33 |
-
'sec-fetch-dest': 'empty',
|
34 |
-
'sec-fetch-mode': 'cors',
|
35 |
-
'sec-fetch-site': 'same-site',
|
36 |
-
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'
|
37 |
-
}
|
38 |
-
data ={
|
39 |
-
"prompt": format_prompt(messages),
|
40 |
-
"options": {},
|
41 |
-
"userId": f"#/chat/{random.randint(1,99999999)}",
|
42 |
-
"usingContext": True
|
43 |
-
}
|
44 |
-
response = requests.post("https://ai-api20.wuguokai.xyz/api/chat-process", headers=headers, timeout=3, json=data, proxies=kwargs['proxy'] if 'proxy' in kwargs else {})
|
45 |
-
_split = response.text.split("> 若回答失败请重试或多刷新几次界面后重试")
|
46 |
-
if response.status_code == 200:
|
47 |
-
if len(_split) > 1:
|
48 |
-
yield _split[1].strip()
|
49 |
-
else:
|
50 |
-
yield _split[0].strip()
|
51 |
-
else:
|
52 |
-
raise Exception(f"Error: {response.status_code} {response.reason}")
|
53 |
-
|
54 |
-
@classmethod
|
55 |
-
@property
|
56 |
-
def params(cls):
|
57 |
-
params = [
|
58 |
-
("model", "str"),
|
59 |
-
("messages", "list[dict[str, str]]"),
|
60 |
-
("stream", "bool")
|
61 |
-
]
|
62 |
-
param = ", ".join([": ".join(p) for p in params])
|
63 |
-
return f"g4f.provider.{cls.__name__} supports: ({param})"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Aer0xander/sd-to-diffusers/hf_utils.py
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
from huggingface_hub import get_hf_file_metadata, hf_hub_url, hf_hub_download, scan_cache_dir, whoami, list_models
|
2 |
-
|
3 |
-
|
4 |
-
def get_my_model_names(token):
|
5 |
-
|
6 |
-
try:
|
7 |
-
author = whoami(token=token)
|
8 |
-
model_infos = list_models(author=author["name"], use_auth_token=token)
|
9 |
-
return [model.modelId for model in model_infos], None
|
10 |
-
|
11 |
-
except Exception as e:
|
12 |
-
return [], e
|
13 |
-
|
14 |
-
def download_file(repo_id: str, filename: str, token: str):
|
15 |
-
"""Download a file from a repo on the Hugging Face Hub.
|
16 |
-
|
17 |
-
Returns:
|
18 |
-
file_path (:obj:`str`): The path to the downloaded file.
|
19 |
-
revision (:obj:`str`): The commit hash of the file.
|
20 |
-
"""
|
21 |
-
|
22 |
-
md = get_hf_file_metadata(hf_hub_url(repo_id=repo_id, filename=filename), token=token)
|
23 |
-
revision = md.commit_hash
|
24 |
-
|
25 |
-
file_path = hf_hub_download(repo_id=repo_id, filename=filename, revision=revision, token=token)
|
26 |
-
|
27 |
-
return file_path, revision
|
28 |
-
|
29 |
-
def delete_file(revision: str):
|
30 |
-
"""Delete a file from local cache.
|
31 |
-
|
32 |
-
Args:
|
33 |
-
revision (:obj:`str`): The commit hash of the file.
|
34 |
-
Returns:
|
35 |
-
None
|
36 |
-
"""
|
37 |
-
scan_cache_dir().delete_revisions(revision).execute()
|
38 |
-
|
39 |
-
def get_pr_url(api, repo_id, title):
|
40 |
-
try:
|
41 |
-
discussions = api.get_repo_discussions(repo_id=repo_id)
|
42 |
-
except Exception:
|
43 |
-
return None
|
44 |
-
for discussion in discussions:
|
45 |
-
if (
|
46 |
-
discussion.status == "open"
|
47 |
-
and discussion.is_pull_request
|
48 |
-
and discussion.title == title
|
49 |
-
):
|
50 |
-
return f"https://huggingface.co/{repo_id}/discussions/{discussion.num}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Ameaou/academic-chatgpt3.1/crazy_functions/test_project/cpp/longcode/prod_cons.h
DELETED
@@ -1,433 +0,0 @@
|
|
1 |
-
#pragma once
|
2 |
-
|
3 |
-
#include <atomic>
|
4 |
-
#include <utility>
|
5 |
-
#include <cstring>
|
6 |
-
#include <type_traits>
|
7 |
-
#include <cstdint>
|
8 |
-
|
9 |
-
#include "libipc/def.h"
|
10 |
-
|
11 |
-
#include "libipc/platform/detail.h"
|
12 |
-
#include "libipc/circ/elem_def.h"
|
13 |
-
#include "libipc/utility/log.h"
|
14 |
-
#include "libipc/utility/utility.h"
|
15 |
-
|
16 |
-
namespace ipc {
|
17 |
-
|
18 |
-
////////////////////////////////////////////////////////////////
|
19 |
-
/// producer-consumer implementation
|
20 |
-
////////////////////////////////////////////////////////////////
|
21 |
-
|
22 |
-
template <typename Flag>
|
23 |
-
struct prod_cons_impl;
|
24 |
-
|
25 |
-
template <>
|
26 |
-
struct prod_cons_impl<wr<relat::single, relat::single, trans::unicast>> {
|
27 |
-
|
28 |
-
template <std::size_t DataSize, std::size_t AlignSize>
|
29 |
-
struct elem_t {
|
30 |
-
std::aligned_storage_t<DataSize, AlignSize> data_ {};
|
31 |
-
};
|
32 |
-
|
33 |
-
alignas(cache_line_size) std::atomic<circ::u2_t> rd_; // read index
|
34 |
-
alignas(cache_line_size) std::atomic<circ::u2_t> wt_; // write index
|
35 |
-
|
36 |
-
constexpr circ::u2_t cursor() const noexcept {
|
37 |
-
return 0;
|
38 |
-
}
|
39 |
-
|
40 |
-
template <typename W, typename F, typename E>
|
41 |
-
bool push(W* /*wrapper*/, F&& f, E* elems) {
|
42 |
-
auto cur_wt = circ::index_of(wt_.load(std::memory_order_relaxed));
|
43 |
-
if (cur_wt == circ::index_of(rd_.load(std::memory_order_acquire) - 1)) {
|
44 |
-
return false; // full
|
45 |
-
}
|
46 |
-
std::forward<F>(f)(&(elems[cur_wt].data_));
|
47 |
-
wt_.fetch_add(1, std::memory_order_release);
|
48 |
-
return true;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* In single-single-unicast, 'force_push' means 'no reader' or 'the only one reader is dead'.
|
53 |
-
* So we could just disconnect all connections of receiver, and return false.
|
54 |
-
*/
|
55 |
-
template <typename W, typename F, typename E>
|
56 |
-
bool force_push(W* wrapper, F&&, E*) {
|
57 |
-
wrapper->elems()->disconnect_receiver(~static_cast<circ::cc_t>(0u));
|
58 |
-
return false;
|
59 |
-
}
|
60 |
-
|
61 |
-
template <typename W, typename F, typename R, typename E>
|
62 |
-
bool pop(W* /*wrapper*/, circ::u2_t& /*cur*/, F&& f, R&& out, E* elems) {
|
63 |
-
auto cur_rd = circ::index_of(rd_.load(std::memory_order_relaxed));
|
64 |
-
if (cur_rd == circ::index_of(wt_.load(std::memory_order_acquire))) {
|
65 |
-
return false; // empty
|
66 |
-
}
|
67 |
-
std::forward<F>(f)(&(elems[cur_rd].data_));
|
68 |
-
std::forward<R>(out)(true);
|
69 |
-
rd_.fetch_add(1, std::memory_order_release);
|
70 |
-
return true;
|
71 |
-
}
|
72 |
-
};
|
73 |
-
|
74 |
-
template <>
|
75 |
-
struct prod_cons_impl<wr<relat::single, relat::multi , trans::unicast>>
|
76 |
-
: prod_cons_impl<wr<relat::single, relat::single, trans::unicast>> {
|
77 |
-
|
78 |
-
template <typename W, typename F, typename E>
|
79 |
-
bool force_push(W* wrapper, F&&, E*) {
|
80 |
-
wrapper->elems()->disconnect_receiver(1);
|
81 |
-
return false;
|
82 |
-
}
|
83 |
-
|
84 |
-
template <typename W, typename F, typename R,
|
85 |
-
template <std::size_t, std::size_t> class E, std::size_t DS, std::size_t AS>
|
86 |
-
bool pop(W* /*wrapper*/, circ::u2_t& /*cur*/, F&& f, R&& out, E<DS, AS>* elems) {
|
87 |
-
byte_t buff[DS];
|
88 |
-
for (unsigned k = 0;;) {
|
89 |
-
auto cur_rd = rd_.load(std::memory_order_relaxed);
|
90 |
-
if (circ::index_of(cur_rd) ==
|
91 |
-
circ::index_of(wt_.load(std::memory_order_acquire))) {
|
92 |
-
return false; // empty
|
93 |
-
}
|
94 |
-
std::memcpy(buff, &(elems[circ::index_of(cur_rd)].data_), sizeof(buff));
|
95 |
-
if (rd_.compare_exchange_weak(cur_rd, cur_rd + 1, std::memory_order_release)) {
|
96 |
-
std::forward<F>(f)(buff);
|
97 |
-
std::forward<R>(out)(true);
|
98 |
-
return true;
|
99 |
-
}
|
100 |
-
ipc::yield(k);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
};
|
104 |
-
|
105 |
-
template <>
|
106 |
-
struct prod_cons_impl<wr<relat::multi , relat::multi, trans::unicast>>
|
107 |
-
: prod_cons_impl<wr<relat::single, relat::multi, trans::unicast>> {
|
108 |
-
|
109 |
-
using flag_t = std::uint64_t;
|
110 |
-
|
111 |
-
template <std::size_t DataSize, std::size_t AlignSize>
|
112 |
-
struct elem_t {
|
113 |
-
std::aligned_storage_t<DataSize, AlignSize> data_ {};
|
114 |
-
std::atomic<flag_t> f_ct_ { 0 }; // commit flag
|
115 |
-
};
|
116 |
-
|
117 |
-
alignas(cache_line_size) std::atomic<circ::u2_t> ct_; // commit index
|
118 |
-
|
119 |
-
template <typename W, typename F, typename E>
|
120 |
-
bool push(W* /*wrapper*/, F&& f, E* elems) {
|
121 |
-
circ::u2_t cur_ct, nxt_ct;
|
122 |
-
for (unsigned k = 0;;) {
|
123 |
-
cur_ct = ct_.load(std::memory_order_relaxed);
|
124 |
-
if (circ::index_of(nxt_ct = cur_ct + 1) ==
|
125 |
-
circ::index_of(rd_.load(std::memory_order_acquire))) {
|
126 |
-
return false; // full
|
127 |
-
}
|
128 |
-
if (ct_.compare_exchange_weak(cur_ct, nxt_ct, std::memory_order_acq_rel)) {
|
129 |
-
break;
|
130 |
-
}
|
131 |
-
ipc::yield(k);
|
132 |
-
}
|
133 |
-
auto* el = elems + circ::index_of(cur_ct);
|
134 |
-
std::forward<F>(f)(&(el->data_));
|
135 |
-
// set flag & try update wt
|
136 |
-
el->f_ct_.store(~static_cast<flag_t>(cur_ct), std::memory_order_release);
|
137 |
-
while (1) {
|
138 |
-
auto cac_ct = el->f_ct_.load(std::memory_order_acquire);
|
139 |
-
if (cur_ct != wt_.load(std::memory_order_relaxed)) {
|
140 |
-
return true;
|
141 |
-
}
|
142 |
-
if ((~cac_ct) != cur_ct) {
|
143 |
-
return true;
|
144 |
-
}
|
145 |
-
if (!el->f_ct_.compare_exchange_strong(cac_ct, 0, std::memory_order_relaxed)) {
|
146 |
-
return true;
|
147 |
-
}
|
148 |
-
wt_.store(nxt_ct, std::memory_order_release);
|
149 |
-
cur_ct = nxt_ct;
|
150 |
-
nxt_ct = cur_ct + 1;
|
151 |
-
el = elems + circ::index_of(cur_ct);
|
152 |
-
}
|
153 |
-
return true;
|
154 |
-
}
|
155 |
-
|
156 |
-
template <typename W, typename F, typename E>
|
157 |
-
bool force_push(W* wrapper, F&&, E*) {
|
158 |
-
wrapper->elems()->disconnect_receiver(1);
|
159 |
-
return false;
|
160 |
-
}
|
161 |
-
|
162 |
-
template <typename W, typename F, typename R,
|
163 |
-
template <std::size_t, std::size_t> class E, std::size_t DS, std::size_t AS>
|
164 |
-
bool pop(W* /*wrapper*/, circ::u2_t& /*cur*/, F&& f, R&& out, E<DS, AS>* elems) {
|
165 |
-
byte_t buff[DS];
|
166 |
-
for (unsigned k = 0;;) {
|
167 |
-
auto cur_rd = rd_.load(std::memory_order_relaxed);
|
168 |
-
auto cur_wt = wt_.load(std::memory_order_acquire);
|
169 |
-
auto id_rd = circ::index_of(cur_rd);
|
170 |
-
auto id_wt = circ::index_of(cur_wt);
|
171 |
-
if (id_rd == id_wt) {
|
172 |
-
auto* el = elems + id_wt;
|
173 |
-
auto cac_ct = el->f_ct_.load(std::memory_order_acquire);
|
174 |
-
if ((~cac_ct) != cur_wt) {
|
175 |
-
return false; // empty
|
176 |
-
}
|
177 |
-
if (el->f_ct_.compare_exchange_weak(cac_ct, 0, std::memory_order_relaxed)) {
|
178 |
-
wt_.store(cur_wt + 1, std::memory_order_release);
|
179 |
-
}
|
180 |
-
k = 0;
|
181 |
-
}
|
182 |
-
else {
|
183 |
-
std::memcpy(buff, &(elems[circ::index_of(cur_rd)].data_), sizeof(buff));
|
184 |
-
if (rd_.compare_exchange_weak(cur_rd, cur_rd + 1, std::memory_order_release)) {
|
185 |
-
std::forward<F>(f)(buff);
|
186 |
-
std::forward<R>(out)(true);
|
187 |
-
return true;
|
188 |
-
}
|
189 |
-
ipc::yield(k);
|
190 |
-
}
|
191 |
-
}
|
192 |
-
}
|
193 |
-
};
|
194 |
-
|
195 |
-
template <>
|
196 |
-
struct prod_cons_impl<wr<relat::single, relat::multi, trans::broadcast>> {
|
197 |
-
|
198 |
-
using rc_t = std::uint64_t;
|
199 |
-
|
200 |
-
enum : rc_t {
|
201 |
-
ep_mask = 0x00000000ffffffffull,
|
202 |
-
ep_incr = 0x0000000100000000ull
|
203 |
-
};
|
204 |
-
|
205 |
-
template <std::size_t DataSize, std::size_t AlignSize>
|
206 |
-
struct elem_t {
|
207 |
-
std::aligned_storage_t<DataSize, AlignSize> data_ {};
|
208 |
-
std::atomic<rc_t> rc_ { 0 }; // read-counter
|
209 |
-
};
|
210 |
-
|
211 |
-
alignas(cache_line_size) std::atomic<circ::u2_t> wt_; // write index
|
212 |
-
alignas(cache_line_size) rc_t epoch_ { 0 }; // only one writer
|
213 |
-
|
214 |
-
circ::u2_t cursor() const noexcept {
|
215 |
-
return wt_.load(std::memory_order_acquire);
|
216 |
-
}
|
217 |
-
|
218 |
-
template <typename W, typename F, typename E>
|
219 |
-
bool push(W* wrapper, F&& f, E* elems) {
|
220 |
-
E* el;
|
221 |
-
for (unsigned k = 0;;) {
|
222 |
-
circ::cc_t cc = wrapper->elems()->connections(std::memory_order_relaxed);
|
223 |
-
if (cc == 0) return false; // no reader
|
224 |
-
el = elems + circ::index_of(wt_.load(std::memory_order_relaxed));
|
225 |
-
// check all consumers have finished reading this element
|
226 |
-
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
227 |
-
circ::cc_t rem_cc = cur_rc & ep_mask;
|
228 |
-
if ((cc & rem_cc) && ((cur_rc & ~ep_mask) == epoch_)) {
|
229 |
-
return false; // has not finished yet
|
230 |
-
}
|
231 |
-
// consider rem_cc to be 0 here
|
232 |
-
if (el->rc_.compare_exchange_weak(
|
233 |
-
cur_rc, epoch_ | static_cast<rc_t>(cc), std::memory_order_release)) {
|
234 |
-
break;
|
235 |
-
}
|
236 |
-
ipc::yield(k);
|
237 |
-
}
|
238 |
-
std::forward<F>(f)(&(el->data_));
|
239 |
-
wt_.fetch_add(1, std::memory_order_release);
|
240 |
-
return true;
|
241 |
-
}
|
242 |
-
|
243 |
-
template <typename W, typename F, typename E>
|
244 |
-
bool force_push(W* wrapper, F&& f, E* elems) {
|
245 |
-
E* el;
|
246 |
-
epoch_ += ep_incr;
|
247 |
-
for (unsigned k = 0;;) {
|
248 |
-
circ::cc_t cc = wrapper->elems()->connections(std::memory_order_relaxed);
|
249 |
-
if (cc == 0) return false; // no reader
|
250 |
-
el = elems + circ::index_of(wt_.load(std::memory_order_relaxed));
|
251 |
-
// check all consumers have finished reading this element
|
252 |
-
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
253 |
-
circ::cc_t rem_cc = cur_rc & ep_mask;
|
254 |
-
if (cc & rem_cc) {
|
255 |
-
ipc::log("force_push: k = %u, cc = %u, rem_cc = %u\n", k, cc, rem_cc);
|
256 |
-
cc = wrapper->elems()->disconnect_receiver(rem_cc); // disconnect all invalid readers
|
257 |
-
if (cc == 0) return false; // no reader
|
258 |
-
}
|
259 |
-
// just compare & exchange
|
260 |
-
if (el->rc_.compare_exchange_weak(
|
261 |
-
cur_rc, epoch_ | static_cast<rc_t>(cc), std::memory_order_release)) {
|
262 |
-
break;
|
263 |
-
}
|
264 |
-
ipc::yield(k);
|
265 |
-
}
|
266 |
-
std::forward<F>(f)(&(el->data_));
|
267 |
-
wt_.fetch_add(1, std::memory_order_release);
|
268 |
-
return true;
|
269 |
-
}
|
270 |
-
|
271 |
-
template <typename W, typename F, typename R, typename E>
|
272 |
-
bool pop(W* wrapper, circ::u2_t& cur, F&& f, R&& out, E* elems) {
|
273 |
-
if (cur == cursor()) return false; // acquire
|
274 |
-
auto* el = elems + circ::index_of(cur++);
|
275 |
-
std::forward<F>(f)(&(el->data_));
|
276 |
-
for (unsigned k = 0;;) {
|
277 |
-
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
278 |
-
if ((cur_rc & ep_mask) == 0) {
|
279 |
-
std::forward<R>(out)(true);
|
280 |
-
return true;
|
281 |
-
}
|
282 |
-
auto nxt_rc = cur_rc & ~static_cast<rc_t>(wrapper->connected_id());
|
283 |
-
if (el->rc_.compare_exchange_weak(cur_rc, nxt_rc, std::memory_order_release)) {
|
284 |
-
std::forward<R>(out)((nxt_rc & ep_mask) == 0);
|
285 |
-
return true;
|
286 |
-
}
|
287 |
-
ipc::yield(k);
|
288 |
-
}
|
289 |
-
}
|
290 |
-
};
|
291 |
-
|
292 |
-
template <>
|
293 |
-
struct prod_cons_impl<wr<relat::multi, relat::multi, trans::broadcast>> {
|
294 |
-
|
295 |
-
using rc_t = std::uint64_t;
|
296 |
-
using flag_t = std::uint64_t;
|
297 |
-
|
298 |
-
enum : rc_t {
|
299 |
-
rc_mask = 0x00000000ffffffffull,
|
300 |
-
ep_mask = 0x00ffffffffffffffull,
|
301 |
-
ep_incr = 0x0100000000000000ull,
|
302 |
-
ic_mask = 0xff000000ffffffffull,
|
303 |
-
ic_incr = 0x0000000100000000ull
|
304 |
-
};
|
305 |
-
|
306 |
-
template <std::size_t DataSize, std::size_t AlignSize>
|
307 |
-
struct elem_t {
|
308 |
-
std::aligned_storage_t<DataSize, AlignSize> data_ {};
|
309 |
-
std::atomic<rc_t > rc_ { 0 }; // read-counter
|
310 |
-
std::atomic<flag_t> f_ct_ { 0 }; // commit flag
|
311 |
-
};
|
312 |
-
|
313 |
-
alignas(cache_line_size) std::atomic<circ::u2_t> ct_; // commit index
|
314 |
-
alignas(cache_line_size) std::atomic<rc_t> epoch_ { 0 };
|
315 |
-
|
316 |
-
circ::u2_t cursor() const noexcept {
|
317 |
-
return ct_.load(std::memory_order_acquire);
|
318 |
-
}
|
319 |
-
|
320 |
-
constexpr static rc_t inc_rc(rc_t rc) noexcept {
|
321 |
-
return (rc & ic_mask) | ((rc + ic_incr) & ~ic_mask);
|
322 |
-
}
|
323 |
-
|
324 |
-
constexpr static rc_t inc_mask(rc_t rc) noexcept {
|
325 |
-
return inc_rc(rc) & ~rc_mask;
|
326 |
-
}
|
327 |
-
|
328 |
-
template <typename W, typename F, typename E>
|
329 |
-
bool push(W* wrapper, F&& f, E* elems) {
|
330 |
-
E* el;
|
331 |
-
circ::u2_t cur_ct;
|
332 |
-
rc_t epoch = epoch_.load(std::memory_order_acquire);
|
333 |
-
for (unsigned k = 0;;) {
|
334 |
-
circ::cc_t cc = wrapper->elems()->connections(std::memory_order_relaxed);
|
335 |
-
if (cc == 0) return false; // no reader
|
336 |
-
el = elems + circ::index_of(cur_ct = ct_.load(std::memory_order_relaxed));
|
337 |
-
// check all consumers have finished reading this element
|
338 |
-
auto cur_rc = el->rc_.load(std::memory_order_relaxed);
|
339 |
-
circ::cc_t rem_cc = cur_rc & rc_mask;
|
340 |
-
if ((cc & rem_cc) && ((cur_rc & ~ep_mask) == epoch)) {
|
341 |
-
return false; // has not finished yet
|
342 |
-
}
|
343 |
-
else if (!rem_cc) {
|
344 |
-
auto cur_fl = el->f_ct_.load(std::memory_order_acquire);
|
345 |
-
if ((cur_fl != cur_ct) && cur_fl) {
|
346 |
-
return false; // full
|
347 |
-
}
|
348 |
-
}
|
349 |
-
// consider rem_cc to be 0 here
|
350 |
-
if (el->rc_.compare_exchange_weak(
|
351 |
-
cur_rc, inc_mask(epoch | (cur_rc & ep_mask)) | static_cast<rc_t>(cc), std::memory_order_relaxed) &&
|
352 |
-
epoch_.compare_exchange_weak(epoch, epoch, std::memory_order_acq_rel)) {
|
353 |
-
break;
|
354 |
-
}
|
355 |
-
ipc::yield(k);
|
356 |
-
}
|
357 |
-
// only one thread/process would touch here at one time
|
358 |
-
ct_.store(cur_ct + 1, std::memory_order_release);
|
359 |
-
std::forward<F>(f)(&(el->data_));
|
360 |
-
// set flag & try update wt
|
361 |
-
el->f_ct_.store(~static_cast<flag_t>(cur_ct), std::memory_order_release);
|
362 |
-
return true;
|
363 |
-
}
|
364 |
-
|
365 |
-
template <typename W, typename F, typename E>
|
366 |
-
bool force_push(W* wrapper, F&& f, E* elems) {
|
367 |
-
E* el;
|
368 |
-
circ::u2_t cur_ct;
|
369 |
-
rc_t epoch = epoch_.fetch_add(ep_incr, std::memory_order_release) + ep_incr;
|
370 |
-
for (unsigned k = 0;;) {
|
371 |
-
circ::cc_t cc = wrapper->elems()->connections(std::memory_order_relaxed);
|
372 |
-
if (cc == 0) return false; // no reader
|
373 |
-
el = elems + circ::index_of(cur_ct = ct_.load(std::memory_order_relaxed));
|
374 |
-
// check all consumers have finished reading this element
|
375 |
-
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
376 |
-
circ::cc_t rem_cc = cur_rc & rc_mask;
|
377 |
-
if (cc & rem_cc) {
|
378 |
-
ipc::log("force_push: k = %u, cc = %u, rem_cc = %u\n", k, cc, rem_cc);
|
379 |
-
cc = wrapper->elems()->disconnect_receiver(rem_cc); // disconnect all invalid readers
|
380 |
-
if (cc == 0) return false; // no reader
|
381 |
-
}
|
382 |
-
// just compare & exchange
|
383 |
-
if (el->rc_.compare_exchange_weak(
|
384 |
-
cur_rc, inc_mask(epoch | (cur_rc & ep_mask)) | static_cast<rc_t>(cc), std::memory_order_relaxed)) {
|
385 |
-
if (epoch == epoch_.load(std::memory_order_acquire)) {
|
386 |
-
break;
|
387 |
-
}
|
388 |
-
else if (push(wrapper, std::forward<F>(f), elems)) {
|
389 |
-
return true;
|
390 |
-
}
|
391 |
-
epoch = epoch_.fetch_add(ep_incr, std::memory_order_release) + ep_incr;
|
392 |
-
}
|
393 |
-
ipc::yield(k);
|
394 |
-
}
|
395 |
-
// only one thread/process would touch here at one time
|
396 |
-
ct_.store(cur_ct + 1, std::memory_order_release);
|
397 |
-
std::forward<F>(f)(&(el->data_));
|
398 |
-
// set flag & try update wt
|
399 |
-
el->f_ct_.store(~static_cast<flag_t>(cur_ct), std::memory_order_release);
|
400 |
-
return true;
|
401 |
-
}
|
402 |
-
|
403 |
-
template <typename W, typename F, typename R, typename E, std::size_t N>
|
404 |
-
bool pop(W* wrapper, circ::u2_t& cur, F&& f, R&& out, E(& elems)[N]) {
|
405 |
-
auto* el = elems + circ::index_of(cur);
|
406 |
-
auto cur_fl = el->f_ct_.load(std::memory_order_acquire);
|
407 |
-
if (cur_fl != ~static_cast<flag_t>(cur)) {
|
408 |
-
return false; // empty
|
409 |
-
}
|
410 |
-
++cur;
|
411 |
-
std::forward<F>(f)(&(el->data_));
|
412 |
-
for (unsigned k = 0;;) {
|
413 |
-
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
414 |
-
if ((cur_rc & rc_mask) == 0) {
|
415 |
-
std::forward<R>(out)(true);
|
416 |
-
el->f_ct_.store(cur + N - 1, std::memory_order_release);
|
417 |
-
return true;
|
418 |
-
}
|
419 |
-
auto nxt_rc = inc_rc(cur_rc) & ~static_cast<rc_t>(wrapper->connected_id());
|
420 |
-
bool last_one = false;
|
421 |
-
if ((last_one = (nxt_rc & rc_mask) == 0)) {
|
422 |
-
el->f_ct_.store(cur + N - 1, std::memory_order_release);
|
423 |
-
}
|
424 |
-
if (el->rc_.compare_exchange_weak(cur_rc, nxt_rc, std::memory_order_release)) {
|
425 |
-
std::forward<R>(out)(last_one);
|
426 |
-
return true;
|
427 |
-
}
|
428 |
-
ipc::yield(k);
|
429 |
-
}
|
430 |
-
}
|
431 |
-
};
|
432 |
-
|
433 |
-
} // namespace ipc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Amrrs/DragGan-Inversion/stylegan_human/torch_utils/ops/filtered_lrelu.cpp
DELETED
@@ -1,300 +0,0 @@
|
|
1 |
-
// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
2 |
-
//
|
3 |
-
// NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
-
// and proprietary rights in and to this software, related documentation
|
5 |
-
// and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
-
// distribution of this software and related documentation without an express
|
7 |
-
// license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
-
|
9 |
-
#include <torch/extension.h>
|
10 |
-
#include <ATen/cuda/CUDAContext.h>
|
11 |
-
#include <c10/cuda/CUDAGuard.h>
|
12 |
-
#include "filtered_lrelu.h"
|
13 |
-
|
14 |
-
//------------------------------------------------------------------------
|
15 |
-
|
16 |
-
static std::tuple<torch::Tensor, torch::Tensor, int> filtered_lrelu(
|
17 |
-
torch::Tensor x, torch::Tensor fu, torch::Tensor fd, torch::Tensor b, torch::Tensor si,
|
18 |
-
int up, int down, int px0, int px1, int py0, int py1, int sx, int sy, float gain, float slope, float clamp, bool flip_filters, bool writeSigns)
|
19 |
-
{
|
20 |
-
// Set CUDA device.
|
21 |
-
TORCH_CHECK(x.is_cuda(), "x must reside on CUDA device");
|
22 |
-
const at::cuda::OptionalCUDAGuard device_guard(device_of(x));
|
23 |
-
|
24 |
-
// Validate arguments.
|
25 |
-
TORCH_CHECK(fu.device() == x.device() && fd.device() == x.device() && b.device() == x.device(), "all input tensors must reside on the same device");
|
26 |
-
TORCH_CHECK(fu.dtype() == torch::kFloat && fd.dtype() == torch::kFloat, "fu and fd must be float32");
|
27 |
-
TORCH_CHECK(b.dtype() == x.dtype(), "x and b must have the same dtype");
|
28 |
-
TORCH_CHECK(x.dtype() == torch::kHalf || x.dtype() == torch::kFloat, "x and b must be float16 or float32");
|
29 |
-
TORCH_CHECK(x.dim() == 4, "x must be rank 4");
|
30 |
-
TORCH_CHECK(x.size(0) * x.size(1) <= INT_MAX && x.size(2) <= INT_MAX && x.size(3) <= INT_MAX, "x is too large");
|
31 |
-
TORCH_CHECK(x.numel() > 0, "x is empty");
|
32 |
-
TORCH_CHECK((fu.dim() == 1 || fu.dim() == 2) && (fd.dim() == 1 || fd.dim() == 2), "fu and fd must be rank 1 or 2");
|
33 |
-
TORCH_CHECK(fu.size(0) <= INT_MAX && fu.size(-1) <= INT_MAX, "fu is too large");
|
34 |
-
TORCH_CHECK(fd.size(0) <= INT_MAX && fd.size(-1) <= INT_MAX, "fd is too large");
|
35 |
-
TORCH_CHECK(fu.numel() > 0, "fu is empty");
|
36 |
-
TORCH_CHECK(fd.numel() > 0, "fd is empty");
|
37 |
-
TORCH_CHECK(b.dim() == 1 && b.size(0) == x.size(1), "b must be a vector with the same number of channels as x");
|
38 |
-
TORCH_CHECK(up >= 1 && down >= 1, "up and down must be at least 1");
|
39 |
-
|
40 |
-
// Figure out how much shared memory is available on the device.
|
41 |
-
int maxSharedBytes = 0;
|
42 |
-
AT_CUDA_CHECK(cudaDeviceGetAttribute(&maxSharedBytes, cudaDevAttrMaxSharedMemoryPerBlockOptin, x.device().index()));
|
43 |
-
int sharedKB = maxSharedBytes >> 10;
|
44 |
-
|
45 |
-
// Populate enough launch parameters to check if a CUDA kernel exists.
|
46 |
-
filtered_lrelu_kernel_params p;
|
47 |
-
p.up = up;
|
48 |
-
p.down = down;
|
49 |
-
p.fuShape = make_int2((int)fu.size(-1), fu.dim() == 2 ? (int)fu.size(0) : 0); // shape [n, 0] indicates separable filter.
|
50 |
-
p.fdShape = make_int2((int)fd.size(-1), fd.dim() == 2 ? (int)fd.size(0) : 0);
|
51 |
-
filtered_lrelu_kernel_spec test_spec = choose_filtered_lrelu_kernel<float, int32_t, false, false>(p, sharedKB);
|
52 |
-
if (!test_spec.exec)
|
53 |
-
{
|
54 |
-
// No kernel found - return empty tensors and indicate missing kernel with return code of -1.
|
55 |
-
return std::make_tuple(torch::Tensor(), torch::Tensor(), -1);
|
56 |
-
}
|
57 |
-
|
58 |
-
// Input/output element size.
|
59 |
-
int64_t sz = (x.dtype() == torch::kHalf) ? 2 : 4;
|
60 |
-
|
61 |
-
// Input sizes.
|
62 |
-
int64_t xw = (int)x.size(3);
|
63 |
-
int64_t xh = (int)x.size(2);
|
64 |
-
int64_t fut_w = (int)fu.size(-1) - 1;
|
65 |
-
int64_t fut_h = (int)fu.size(0) - 1;
|
66 |
-
int64_t fdt_w = (int)fd.size(-1) - 1;
|
67 |
-
int64_t fdt_h = (int)fd.size(0) - 1;
|
68 |
-
|
69 |
-
// Logical size of upsampled buffer.
|
70 |
-
int64_t cw = xw * up + (px0 + px1) - fut_w;
|
71 |
-
int64_t ch = xh * up + (py0 + py1) - fut_h;
|
72 |
-
TORCH_CHECK(cw > fdt_w && ch > fdt_h, "upsampled buffer must be at least the size of downsampling filter");
|
73 |
-
TORCH_CHECK(cw <= INT_MAX && ch <= INT_MAX, "upsampled buffer is too large");
|
74 |
-
|
75 |
-
// Compute output size and allocate.
|
76 |
-
int64_t yw = (cw - fdt_w + (down - 1)) / down;
|
77 |
-
int64_t yh = (ch - fdt_h + (down - 1)) / down;
|
78 |
-
TORCH_CHECK(yw > 0 && yh > 0, "output must be at least 1x1");
|
79 |
-
TORCH_CHECK(yw <= INT_MAX && yh <= INT_MAX, "output is too large");
|
80 |
-
torch::Tensor y = torch::empty({x.size(0), x.size(1), yh, yw}, x.options(), x.suggest_memory_format());
|
81 |
-
|
82 |
-
// Allocate sign tensor.
|
83 |
-
torch::Tensor so;
|
84 |
-
torch::Tensor s = si;
|
85 |
-
bool readSigns = !!s.numel();
|
86 |
-
int64_t sw_active = 0; // Active width of sign tensor.
|
87 |
-
if (writeSigns)
|
88 |
-
{
|
89 |
-
sw_active = yw * down - (down - 1) + fdt_w; // Active width in elements.
|
90 |
-
int64_t sh = yh * down - (down - 1) + fdt_h; // Height = active height.
|
91 |
-
int64_t sw = (sw_active + 15) & ~15; // Width = active width in elements, rounded up to multiple of 16.
|
92 |
-
TORCH_CHECK(sh <= INT_MAX && (sw >> 2) <= INT_MAX, "signs is too large");
|
93 |
-
s = so = torch::empty({x.size(0), x.size(1), sh, sw >> 2}, x.options().dtype(torch::kUInt8), at::MemoryFormat::Contiguous);
|
94 |
-
}
|
95 |
-
else if (readSigns)
|
96 |
-
sw_active = s.size(3) << 2;
|
97 |
-
|
98 |
-
// Validate sign tensor if in use.
|
99 |
-
if (readSigns || writeSigns)
|
100 |
-
{
|
101 |
-
TORCH_CHECK(s.is_contiguous(), "signs must be contiguous");
|
102 |
-
TORCH_CHECK(s.dtype() == torch::kUInt8, "signs must be uint8");
|
103 |
-
TORCH_CHECK(s.device() == x.device(), "signs must reside on the same device as x");
|
104 |
-
TORCH_CHECK(s.dim() == 4, "signs must be rank 4");
|
105 |
-
TORCH_CHECK(s.size(0) == x.size(0) && s.size(1) == x.size(1), "signs must have same batch & channels as x");
|
106 |
-
TORCH_CHECK(s.size(2) <= INT_MAX && s.size(3) <= INT_MAX, "signs is too large");
|
107 |
-
}
|
108 |
-
|
109 |
-
// Populate rest of CUDA kernel parameters.
|
110 |
-
p.x = x.data_ptr();
|
111 |
-
p.y = y.data_ptr();
|
112 |
-
p.b = b.data_ptr();
|
113 |
-
p.s = (readSigns || writeSigns) ? s.data_ptr<unsigned char>() : 0;
|
114 |
-
p.fu = fu.data_ptr<float>();
|
115 |
-
p.fd = fd.data_ptr<float>();
|
116 |
-
p.pad0 = make_int2(px0, py0);
|
117 |
-
p.gain = gain;
|
118 |
-
p.slope = slope;
|
119 |
-
p.clamp = clamp;
|
120 |
-
p.flip = (flip_filters) ? 1 : 0;
|
121 |
-
p.xShape = make_int4((int)x.size(3), (int)x.size(2), (int)x.size(1), (int)x.size(0));
|
122 |
-
p.yShape = make_int4((int)y.size(3), (int)y.size(2), (int)y.size(1), (int)y.size(0));
|
123 |
-
p.sShape = (readSigns || writeSigns) ? make_int2((int)s.size(3), (int)s.size(2)) : make_int2(0, 0); // Width is in bytes. Contiguous.
|
124 |
-
p.sOfs = make_int2(sx, sy);
|
125 |
-
p.swLimit = (sw_active + 3) >> 2; // Rounded up to bytes.
|
126 |
-
|
127 |
-
// x, y, b strides are in bytes.
|
128 |
-
p.xStride = make_longlong4(sz * x.stride(3), sz * x.stride(2), sz * x.stride(1), sz * x.stride(0));
|
129 |
-
p.yStride = make_longlong4(sz * y.stride(3), sz * y.stride(2), sz * y.stride(1), sz * y.stride(0));
|
130 |
-
p.bStride = sz * b.stride(0);
|
131 |
-
|
132 |
-
// fu, fd strides are in elements.
|
133 |
-
p.fuStride = make_longlong3(fu.stride(-1), fu.dim() == 2 ? fu.stride(0) : 0, 0);
|
134 |
-
p.fdStride = make_longlong3(fd.stride(-1), fd.dim() == 2 ? fd.stride(0) : 0, 0);
|
135 |
-
|
136 |
-
// Determine if indices don't fit in int32. Support negative strides although Torch currently never produces those.
|
137 |
-
bool index64b = false;
|
138 |
-
if (std::abs(p.bStride * x.size(1)) > INT_MAX) index64b = true;
|
139 |
-
if (std::min(x.size(0) * p.xStride.w, 0ll) + std::min(x.size(1) * p.xStride.z, 0ll) + std::min(x.size(2) * p.xStride.y, 0ll) + std::min(x.size(3) * p.xStride.x, 0ll) < -INT_MAX) index64b = true;
|
140 |
-
if (std::max(x.size(0) * p.xStride.w, 0ll) + std::max(x.size(1) * p.xStride.z, 0ll) + std::max(x.size(2) * p.xStride.y, 0ll) + std::max(x.size(3) * p.xStride.x, 0ll) > INT_MAX) index64b = true;
|
141 |
-
if (std::min(y.size(0) * p.yStride.w, 0ll) + std::min(y.size(1) * p.yStride.z, 0ll) + std::min(y.size(2) * p.yStride.y, 0ll) + std::min(y.size(3) * p.yStride.x, 0ll) < -INT_MAX) index64b = true;
|
142 |
-
if (std::max(y.size(0) * p.yStride.w, 0ll) + std::max(y.size(1) * p.yStride.z, 0ll) + std::max(y.size(2) * p.yStride.y, 0ll) + std::max(y.size(3) * p.yStride.x, 0ll) > INT_MAX) index64b = true;
|
143 |
-
if (s.numel() > INT_MAX) index64b = true;
|
144 |
-
|
145 |
-
// Choose CUDA kernel.
|
146 |
-
filtered_lrelu_kernel_spec spec = { 0 };
|
147 |
-
AT_DISPATCH_FLOATING_TYPES_AND_HALF(x.scalar_type(), "filtered_lrelu_cuda", [&]
|
148 |
-
{
|
149 |
-
if constexpr (sizeof(scalar_t) <= 4) // Exclude doubles. constexpr prevents template instantiation.
|
150 |
-
{
|
151 |
-
// Choose kernel based on index type, datatype and sign read/write modes.
|
152 |
-
if (!index64b && writeSigns && !readSigns) spec = choose_filtered_lrelu_kernel<scalar_t, int32_t, true, false>(p, sharedKB);
|
153 |
-
else if (!index64b && !writeSigns && readSigns) spec = choose_filtered_lrelu_kernel<scalar_t, int32_t, false, true >(p, sharedKB);
|
154 |
-
else if (!index64b && !writeSigns && !readSigns) spec = choose_filtered_lrelu_kernel<scalar_t, int32_t, false, false>(p, sharedKB);
|
155 |
-
else if ( index64b && writeSigns && !readSigns) spec = choose_filtered_lrelu_kernel<scalar_t, int64_t, true, false>(p, sharedKB);
|
156 |
-
else if ( index64b && !writeSigns && readSigns) spec = choose_filtered_lrelu_kernel<scalar_t, int64_t, false, true >(p, sharedKB);
|
157 |
-
else if ( index64b && !writeSigns && !readSigns) spec = choose_filtered_lrelu_kernel<scalar_t, int64_t, false, false>(p, sharedKB);
|
158 |
-
}
|
159 |
-
});
|
160 |
-
TORCH_CHECK(spec.exec, "internal error - CUDA kernel not found") // This should not happen because we tested earlier that kernel exists.
|
161 |
-
|
162 |
-
// Launch CUDA kernel.
|
163 |
-
void* args[] = {&p};
|
164 |
-
int bx = spec.numWarps * 32;
|
165 |
-
int gx = (p.yShape.x - 1) / spec.tileOut.x + 1;
|
166 |
-
int gy = (p.yShape.y - 1) / spec.tileOut.y + 1;
|
167 |
-
int gz = p.yShape.z * p.yShape.w;
|
168 |
-
|
169 |
-
// Repeat multiple horizontal tiles in a CTA?
|
170 |
-
if (spec.xrep)
|
171 |
-
{
|
172 |
-
p.tilesXrep = spec.xrep;
|
173 |
-
p.tilesXdim = gx;
|
174 |
-
|
175 |
-
gx = (gx + p.tilesXrep - 1) / p.tilesXrep;
|
176 |
-
std::swap(gx, gy);
|
177 |
-
}
|
178 |
-
else
|
179 |
-
{
|
180 |
-
p.tilesXrep = 0;
|
181 |
-
p.tilesXdim = 0;
|
182 |
-
}
|
183 |
-
|
184 |
-
// Launch filter setup kernel.
|
185 |
-
AT_CUDA_CHECK(cudaLaunchKernel(spec.setup, 1, 1024, args, 0, at::cuda::getCurrentCUDAStream()));
|
186 |
-
|
187 |
-
// Copy kernels to constant memory.
|
188 |
-
if ( writeSigns && !readSigns) AT_CUDA_CHECK((copy_filters<true, false>(at::cuda::getCurrentCUDAStream())));
|
189 |
-
else if (!writeSigns && readSigns) AT_CUDA_CHECK((copy_filters<false, true >(at::cuda::getCurrentCUDAStream())));
|
190 |
-
else if (!writeSigns && !readSigns) AT_CUDA_CHECK((copy_filters<false, false>(at::cuda::getCurrentCUDAStream())));
|
191 |
-
|
192 |
-
// Set cache and shared memory configurations for main kernel.
|
193 |
-
AT_CUDA_CHECK(cudaFuncSetCacheConfig(spec.exec, cudaFuncCachePreferShared));
|
194 |
-
if (spec.dynamicSharedKB) // Need dynamically allocated shared memory?
|
195 |
-
AT_CUDA_CHECK(cudaFuncSetAttribute(spec.exec, cudaFuncAttributeMaxDynamicSharedMemorySize, spec.dynamicSharedKB << 10));
|
196 |
-
AT_CUDA_CHECK(cudaFuncSetSharedMemConfig(spec.exec, cudaSharedMemBankSizeFourByte));
|
197 |
-
|
198 |
-
// Launch main kernel.
|
199 |
-
const int maxSubGz = 65535; // CUDA maximum for block z dimension.
|
200 |
-
for (int zofs=0; zofs < gz; zofs += maxSubGz) // Do multiple launches if gz is too big.
|
201 |
-
{
|
202 |
-
p.blockZofs = zofs;
|
203 |
-
int subGz = std::min(maxSubGz, gz - zofs);
|
204 |
-
AT_CUDA_CHECK(cudaLaunchKernel(spec.exec, dim3(gx, gy, subGz), bx, args, spec.dynamicSharedKB << 10, at::cuda::getCurrentCUDAStream()));
|
205 |
-
}
|
206 |
-
|
207 |
-
// Done.
|
208 |
-
return std::make_tuple(y, so, 0);
|
209 |
-
}
|
210 |
-
|
211 |
-
//------------------------------------------------------------------------
|
212 |
-
|
213 |
-
static torch::Tensor filtered_lrelu_act(torch::Tensor x, torch::Tensor si, int sx, int sy, float gain, float slope, float clamp, bool writeSigns)
|
214 |
-
{
|
215 |
-
// Set CUDA device.
|
216 |
-
TORCH_CHECK(x.is_cuda(), "x must reside on CUDA device");
|
217 |
-
const at::cuda::OptionalCUDAGuard device_guard(device_of(x));
|
218 |
-
|
219 |
-
// Validate arguments.
|
220 |
-
TORCH_CHECK(x.dim() == 4, "x must be rank 4");
|
221 |
-
TORCH_CHECK(x.size(0) * x.size(1) <= INT_MAX && x.size(2) <= INT_MAX && x.size(3) <= INT_MAX, "x is too large");
|
222 |
-
TORCH_CHECK(x.numel() > 0, "x is empty");
|
223 |
-
TORCH_CHECK(x.dtype() == torch::kHalf || x.dtype() == torch::kFloat || x.dtype() == torch::kDouble, "x must be float16, float32 or float64");
|
224 |
-
|
225 |
-
// Output signs if we don't have sign input.
|
226 |
-
torch::Tensor so;
|
227 |
-
torch::Tensor s = si;
|
228 |
-
bool readSigns = !!s.numel();
|
229 |
-
if (writeSigns)
|
230 |
-
{
|
231 |
-
int64_t sw = x.size(3);
|
232 |
-
sw = (sw + 15) & ~15; // Round to a multiple of 16 for coalescing.
|
233 |
-
s = so = torch::empty({x.size(0), x.size(1), x.size(2), sw >> 2}, x.options().dtype(torch::kUInt8), at::MemoryFormat::Contiguous);
|
234 |
-
}
|
235 |
-
|
236 |
-
// Validate sign tensor if in use.
|
237 |
-
if (readSigns || writeSigns)
|
238 |
-
{
|
239 |
-
TORCH_CHECK(s.is_contiguous(), "signs must be contiguous");
|
240 |
-
TORCH_CHECK(s.dtype() == torch::kUInt8, "signs must be uint8");
|
241 |
-
TORCH_CHECK(s.device() == x.device(), "signs must reside on the same device as x");
|
242 |
-
TORCH_CHECK(s.dim() == 4, "signs must be rank 4");
|
243 |
-
TORCH_CHECK(s.size(0) == x.size(0) && s.size(1) == x.size(1), "signs must have same batch & channels as x");
|
244 |
-
TORCH_CHECK(s.size(2) <= INT_MAX && (s.size(3) << 2) <= INT_MAX, "signs tensor is too large");
|
245 |
-
}
|
246 |
-
|
247 |
-
// Initialize CUDA kernel parameters.
|
248 |
-
filtered_lrelu_act_kernel_params p;
|
249 |
-
p.x = x.data_ptr();
|
250 |
-
p.s = (readSigns || writeSigns) ? s.data_ptr<unsigned char>() : 0;
|
251 |
-
p.gain = gain;
|
252 |
-
p.slope = slope;
|
253 |
-
p.clamp = clamp;
|
254 |
-
p.xShape = make_int4((int)x.size(3), (int)x.size(2), (int)x.size(1), (int)x.size(0));
|
255 |
-
p.xStride = make_longlong4(x.stride(3), x.stride(2), x.stride(1), x.stride(0));
|
256 |
-
p.sShape = (readSigns || writeSigns) ? make_int2((int)s.size(3) << 2, (int)s.size(2)) : make_int2(0, 0); // Width is in elements. Contiguous.
|
257 |
-
p.sOfs = make_int2(sx, sy);
|
258 |
-
|
259 |
-
// Choose CUDA kernel.
|
260 |
-
void* func = 0;
|
261 |
-
AT_DISPATCH_FLOATING_TYPES_AND_HALF(x.scalar_type(), "filtered_lrelu_act_cuda", [&]
|
262 |
-
{
|
263 |
-
if (writeSigns)
|
264 |
-
func = choose_filtered_lrelu_act_kernel<scalar_t, true, false>();
|
265 |
-
else if (readSigns)
|
266 |
-
func = choose_filtered_lrelu_act_kernel<scalar_t, false, true>();
|
267 |
-
else
|
268 |
-
func = choose_filtered_lrelu_act_kernel<scalar_t, false, false>();
|
269 |
-
});
|
270 |
-
TORCH_CHECK(func, "internal error - CUDA kernel not found");
|
271 |
-
|
272 |
-
// Launch CUDA kernel.
|
273 |
-
void* args[] = {&p};
|
274 |
-
int bx = 128; // 4 warps per block.
|
275 |
-
|
276 |
-
// Logical size of launch = writeSigns ? p.s : p.x
|
277 |
-
uint32_t gx = writeSigns ? p.sShape.x : p.xShape.x;
|
278 |
-
uint32_t gy = writeSigns ? p.sShape.y : p.xShape.y;
|
279 |
-
uint32_t gz = p.xShape.z * p.xShape.w; // Same as in p.sShape if signs are in use.
|
280 |
-
gx = (gx - 1) / bx + 1;
|
281 |
-
|
282 |
-
// Make sure grid y and z dimensions are within CUDA launch limits. Kernel loops internally to do the rest.
|
283 |
-
const uint32_t gmax = 65535;
|
284 |
-
gy = std::min(gy, gmax);
|
285 |
-
gz = std::min(gz, gmax);
|
286 |
-
|
287 |
-
// Launch.
|
288 |
-
AT_CUDA_CHECK(cudaLaunchKernel(func, dim3(gx, gy, gz), bx, args, 0, at::cuda::getCurrentCUDAStream()));
|
289 |
-
return so;
|
290 |
-
}
|
291 |
-
|
292 |
-
//------------------------------------------------------------------------
|
293 |
-
|
294 |
-
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
|
295 |
-
{
|
296 |
-
m.def("filtered_lrelu", &filtered_lrelu); // The whole thing.
|
297 |
-
m.def("filtered_lrelu_act_", &filtered_lrelu_act); // Activation and sign tensor handling only. Modifies data tensor in-place.
|
298 |
-
}
|
299 |
-
|
300 |
-
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Androidonnxfork/CivitAi-to-Diffusers/diffusers/src/diffusers/schedulers/scheduling_sde_ve.py
DELETED
@@ -1,288 +0,0 @@
|
|
1 |
-
# Copyright 2023 Google Brain and The HuggingFace Team. All rights reserved.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch
|
16 |
-
|
17 |
-
import math
|
18 |
-
from dataclasses import dataclass
|
19 |
-
from typing import Optional, Tuple, Union
|
20 |
-
|
21 |
-
import torch
|
22 |
-
|
23 |
-
from ..configuration_utils import ConfigMixin, register_to_config
|
24 |
-
from ..utils import BaseOutput, randn_tensor
|
25 |
-
from .scheduling_utils import SchedulerMixin, SchedulerOutput
|
26 |
-
|
27 |
-
|
28 |
-
@dataclass
|
29 |
-
class SdeVeOutput(BaseOutput):
|
30 |
-
"""
|
31 |
-
Output class for the ScoreSdeVeScheduler's step function output.
|
32 |
-
|
33 |
-
Args:
|
34 |
-
prev_sample (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)` for images):
|
35 |
-
Computed sample (x_{t-1}) of previous timestep. `prev_sample` should be used as next model input in the
|
36 |
-
denoising loop.
|
37 |
-
prev_sample_mean (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)` for images):
|
38 |
-
Mean averaged `prev_sample`. Same as `prev_sample`, only mean-averaged over previous timesteps.
|
39 |
-
"""
|
40 |
-
|
41 |
-
prev_sample: torch.FloatTensor
|
42 |
-
prev_sample_mean: torch.FloatTensor
|
43 |
-
|
44 |
-
|
45 |
-
class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin):
|
46 |
-
"""
|
47 |
-
The variance exploding stochastic differential equation (SDE) scheduler.
|
48 |
-
|
49 |
-
For more information, see the original paper: https://arxiv.org/abs/2011.13456
|
50 |
-
|
51 |
-
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
|
52 |
-
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
|
53 |
-
[`SchedulerMixin`] provides general loading and saving functionality via the [`SchedulerMixin.save_pretrained`] and
|
54 |
-
[`~SchedulerMixin.from_pretrained`] functions.
|
55 |
-
|
56 |
-
Args:
|
57 |
-
num_train_timesteps (`int`): number of diffusion steps used to train the model.
|
58 |
-
snr (`float`):
|
59 |
-
coefficient weighting the step from the model_output sample (from the network) to the random noise.
|
60 |
-
sigma_min (`float`):
|
61 |
-
initial noise scale for sigma sequence in sampling procedure. The minimum sigma should mirror the
|
62 |
-
distribution of the data.
|
63 |
-
sigma_max (`float`): maximum value used for the range of continuous timesteps passed into the model.
|
64 |
-
sampling_eps (`float`): the end value of sampling, where timesteps decrease progressively from 1 to
|
65 |
-
epsilon.
|
66 |
-
correct_steps (`int`): number of correction steps performed on a produced sample.
|
67 |
-
"""
|
68 |
-
|
69 |
-
order = 1
|
70 |
-
|
71 |
-
@register_to_config
|
72 |
-
def __init__(
|
73 |
-
self,
|
74 |
-
num_train_timesteps: int = 2000,
|
75 |
-
snr: float = 0.15,
|
76 |
-
sigma_min: float = 0.01,
|
77 |
-
sigma_max: float = 1348.0,
|
78 |
-
sampling_eps: float = 1e-5,
|
79 |
-
correct_steps: int = 1,
|
80 |
-
):
|
81 |
-
# standard deviation of the initial noise distribution
|
82 |
-
self.init_noise_sigma = sigma_max
|
83 |
-
|
84 |
-
# setable values
|
85 |
-
self.timesteps = None
|
86 |
-
|
87 |
-
self.set_sigmas(num_train_timesteps, sigma_min, sigma_max, sampling_eps)
|
88 |
-
|
89 |
-
def scale_model_input(self, sample: torch.FloatTensor, timestep: Optional[int] = None) -> torch.FloatTensor:
|
90 |
-
"""
|
91 |
-
Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
|
92 |
-
current timestep.
|
93 |
-
|
94 |
-
Args:
|
95 |
-
sample (`torch.FloatTensor`): input sample
|
96 |
-
timestep (`int`, optional): current timestep
|
97 |
-
|
98 |
-
Returns:
|
99 |
-
`torch.FloatTensor`: scaled input sample
|
100 |
-
"""
|
101 |
-
return sample
|
102 |
-
|
103 |
-
def set_timesteps(
|
104 |
-
self, num_inference_steps: int, sampling_eps: float = None, device: Union[str, torch.device] = None
|
105 |
-
):
|
106 |
-
"""
|
107 |
-
Sets the continuous timesteps used for the diffusion chain. Supporting function to be run before inference.
|
108 |
-
|
109 |
-
Args:
|
110 |
-
num_inference_steps (`int`):
|
111 |
-
the number of diffusion steps used when generating samples with a pre-trained model.
|
112 |
-
sampling_eps (`float`, optional):
|
113 |
-
final timestep value (overrides value given at Scheduler instantiation).
|
114 |
-
|
115 |
-
"""
|
116 |
-
sampling_eps = sampling_eps if sampling_eps is not None else self.config.sampling_eps
|
117 |
-
|
118 |
-
self.timesteps = torch.linspace(1, sampling_eps, num_inference_steps, device=device)
|
119 |
-
|
120 |
-
def set_sigmas(
|
121 |
-
self, num_inference_steps: int, sigma_min: float = None, sigma_max: float = None, sampling_eps: float = None
|
122 |
-
):
|
123 |
-
"""
|
124 |
-
Sets the noise scales used for the diffusion chain. Supporting function to be run before inference.
|
125 |
-
|
126 |
-
The sigmas control the weight of the `drift` and `diffusion` components of sample update.
|
127 |
-
|
128 |
-
Args:
|
129 |
-
num_inference_steps (`int`):
|
130 |
-
the number of diffusion steps used when generating samples with a pre-trained model.
|
131 |
-
sigma_min (`float`, optional):
|
132 |
-
initial noise scale value (overrides value given at Scheduler instantiation).
|
133 |
-
sigma_max (`float`, optional):
|
134 |
-
final noise scale value (overrides value given at Scheduler instantiation).
|
135 |
-
sampling_eps (`float`, optional):
|
136 |
-
final timestep value (overrides value given at Scheduler instantiation).
|
137 |
-
|
138 |
-
"""
|
139 |
-
sigma_min = sigma_min if sigma_min is not None else self.config.sigma_min
|
140 |
-
sigma_max = sigma_max if sigma_max is not None else self.config.sigma_max
|
141 |
-
sampling_eps = sampling_eps if sampling_eps is not None else self.config.sampling_eps
|
142 |
-
if self.timesteps is None:
|
143 |
-
self.set_timesteps(num_inference_steps, sampling_eps)
|
144 |
-
|
145 |
-
self.sigmas = sigma_min * (sigma_max / sigma_min) ** (self.timesteps / sampling_eps)
|
146 |
-
self.discrete_sigmas = torch.exp(torch.linspace(math.log(sigma_min), math.log(sigma_max), num_inference_steps))
|
147 |
-
self.sigmas = torch.tensor([sigma_min * (sigma_max / sigma_min) ** t for t in self.timesteps])
|
148 |
-
|
149 |
-
def get_adjacent_sigma(self, timesteps, t):
|
150 |
-
return torch.where(
|
151 |
-
timesteps == 0,
|
152 |
-
torch.zeros_like(t.to(timesteps.device)),
|
153 |
-
self.discrete_sigmas[timesteps - 1].to(timesteps.device),
|
154 |
-
)
|
155 |
-
|
156 |
-
def step_pred(
|
157 |
-
self,
|
158 |
-
model_output: torch.FloatTensor,
|
159 |
-
timestep: int,
|
160 |
-
sample: torch.FloatTensor,
|
161 |
-
generator: Optional[torch.Generator] = None,
|
162 |
-
return_dict: bool = True,
|
163 |
-
) -> Union[SdeVeOutput, Tuple]:
|
164 |
-
"""
|
165 |
-
Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
|
166 |
-
process from the learned model outputs (most often the predicted noise).
|
167 |
-
|
168 |
-
Args:
|
169 |
-
model_output (`torch.FloatTensor`): direct output from learned diffusion model.
|
170 |
-
timestep (`int`): current discrete timestep in the diffusion chain.
|
171 |
-
sample (`torch.FloatTensor`):
|
172 |
-
current instance of sample being created by diffusion process.
|
173 |
-
generator: random number generator.
|
174 |
-
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
|
175 |
-
|
176 |
-
Returns:
|
177 |
-
[`~schedulers.scheduling_sde_ve.SdeVeOutput`] or `tuple`: [`~schedulers.scheduling_sde_ve.SdeVeOutput`] if
|
178 |
-
`return_dict` is True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
|
179 |
-
|
180 |
-
"""
|
181 |
-
if self.timesteps is None:
|
182 |
-
raise ValueError(
|
183 |
-
"`self.timesteps` is not set, you need to run 'set_timesteps' after creating the scheduler"
|
184 |
-
)
|
185 |
-
|
186 |
-
timestep = timestep * torch.ones(
|
187 |
-
sample.shape[0], device=sample.device
|
188 |
-
) # torch.repeat_interleave(timestep, sample.shape[0])
|
189 |
-
timesteps = (timestep * (len(self.timesteps) - 1)).long()
|
190 |
-
|
191 |
-
# mps requires indices to be in the same device, so we use cpu as is the default with cuda
|
192 |
-
timesteps = timesteps.to(self.discrete_sigmas.device)
|
193 |
-
|
194 |
-
sigma = self.discrete_sigmas[timesteps].to(sample.device)
|
195 |
-
adjacent_sigma = self.get_adjacent_sigma(timesteps, timestep).to(sample.device)
|
196 |
-
drift = torch.zeros_like(sample)
|
197 |
-
diffusion = (sigma**2 - adjacent_sigma**2) ** 0.5
|
198 |
-
|
199 |
-
# equation 6 in the paper: the model_output modeled by the network is grad_x log pt(x)
|
200 |
-
# also equation 47 shows the analog from SDE models to ancestral sampling methods
|
201 |
-
diffusion = diffusion.flatten()
|
202 |
-
while len(diffusion.shape) < len(sample.shape):
|
203 |
-
diffusion = diffusion.unsqueeze(-1)
|
204 |
-
drift = drift - diffusion**2 * model_output
|
205 |
-
|
206 |
-
# equation 6: sample noise for the diffusion term of
|
207 |
-
noise = randn_tensor(
|
208 |
-
sample.shape, layout=sample.layout, generator=generator, device=sample.device, dtype=sample.dtype
|
209 |
-
)
|
210 |
-
prev_sample_mean = sample - drift # subtract because `dt` is a small negative timestep
|
211 |
-
# TODO is the variable diffusion the correct scaling term for the noise?
|
212 |
-
prev_sample = prev_sample_mean + diffusion * noise # add impact of diffusion field g
|
213 |
-
|
214 |
-
if not return_dict:
|
215 |
-
return (prev_sample, prev_sample_mean)
|
216 |
-
|
217 |
-
return SdeVeOutput(prev_sample=prev_sample, prev_sample_mean=prev_sample_mean)
|
218 |
-
|
219 |
-
def step_correct(
|
220 |
-
self,
|
221 |
-
model_output: torch.FloatTensor,
|
222 |
-
sample: torch.FloatTensor,
|
223 |
-
generator: Optional[torch.Generator] = None,
|
224 |
-
return_dict: bool = True,
|
225 |
-
) -> Union[SchedulerOutput, Tuple]:
|
226 |
-
"""
|
227 |
-
Correct the predicted sample based on the output model_output of the network. This is often run repeatedly
|
228 |
-
after making the prediction for the previous timestep.
|
229 |
-
|
230 |
-
Args:
|
231 |
-
model_output (`torch.FloatTensor`): direct output from learned diffusion model.
|
232 |
-
sample (`torch.FloatTensor`):
|
233 |
-
current instance of sample being created by diffusion process.
|
234 |
-
generator: random number generator.
|
235 |
-
return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
|
236 |
-
|
237 |
-
Returns:
|
238 |
-
[`~schedulers.scheduling_sde_ve.SdeVeOutput`] or `tuple`: [`~schedulers.scheduling_sde_ve.SdeVeOutput`] if
|
239 |
-
`return_dict` is True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
|
240 |
-
|
241 |
-
"""
|
242 |
-
if self.timesteps is None:
|
243 |
-
raise ValueError(
|
244 |
-
"`self.timesteps` is not set, you need to run 'set_timesteps' after creating the scheduler"
|
245 |
-
)
|
246 |
-
|
247 |
-
# For small batch sizes, the paper "suggest replacing norm(z) with sqrt(d), where d is the dim. of z"
|
248 |
-
# sample noise for correction
|
249 |
-
noise = randn_tensor(sample.shape, layout=sample.layout, generator=generator).to(sample.device)
|
250 |
-
|
251 |
-
# compute step size from the model_output, the noise, and the snr
|
252 |
-
grad_norm = torch.norm(model_output.reshape(model_output.shape[0], -1), dim=-1).mean()
|
253 |
-
noise_norm = torch.norm(noise.reshape(noise.shape[0], -1), dim=-1).mean()
|
254 |
-
step_size = (self.config.snr * noise_norm / grad_norm) ** 2 * 2
|
255 |
-
step_size = step_size * torch.ones(sample.shape[0]).to(sample.device)
|
256 |
-
# self.repeat_scalar(step_size, sample.shape[0])
|
257 |
-
|
258 |
-
# compute corrected sample: model_output term and noise term
|
259 |
-
step_size = step_size.flatten()
|
260 |
-
while len(step_size.shape) < len(sample.shape):
|
261 |
-
step_size = step_size.unsqueeze(-1)
|
262 |
-
prev_sample_mean = sample + step_size * model_output
|
263 |
-
prev_sample = prev_sample_mean + ((step_size * 2) ** 0.5) * noise
|
264 |
-
|
265 |
-
if not return_dict:
|
266 |
-
return (prev_sample,)
|
267 |
-
|
268 |
-
return SchedulerOutput(prev_sample=prev_sample)
|
269 |
-
|
270 |
-
def add_noise(
|
271 |
-
self,
|
272 |
-
original_samples: torch.FloatTensor,
|
273 |
-
noise: torch.FloatTensor,
|
274 |
-
timesteps: torch.FloatTensor,
|
275 |
-
) -> torch.FloatTensor:
|
276 |
-
# Make sure sigmas and timesteps have the same device and dtype as original_samples
|
277 |
-
timesteps = timesteps.to(original_samples.device)
|
278 |
-
sigmas = self.discrete_sigmas.to(original_samples.device)[timesteps]
|
279 |
-
noise = (
|
280 |
-
noise * sigmas[:, None, None, None]
|
281 |
-
if noise is not None
|
282 |
-
else torch.randn_like(original_samples) * sigmas[:, None, None, None]
|
283 |
-
)
|
284 |
-
noisy_samples = noise + original_samples
|
285 |
-
return noisy_samples
|
286 |
-
|
287 |
-
def __len__(self):
|
288 |
-
return self.config.num_train_timesteps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Andy1621/uniformer_image_segmentation/configs/deeplabv3/deeplabv3_r50b-d8_512x1024_80k_cityscapes.py
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
_base_ = './deeplabv3_r50-d8_512x1024_80k_cityscapes.py'
|
2 |
-
model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet'))
|
|
|
|
|
|
spaces/Andy1621/uniformer_image_segmentation/configs/encnet/encnet_r50s-d8_512x512_80k_ade20k.py
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
_base_ = [
|
2 |
-
'../_base_/models/encnet_r50-d8.py', '../_base_/datasets/ade20k.py',
|
3 |
-
'../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py'
|
4 |
-
]
|
5 |
-
model = dict(
|
6 |
-
backbone=dict(stem_channels=128),
|
7 |
-
decode_head=dict(num_classes=150),
|
8 |
-
auxiliary_head=dict(num_classes=150))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Andy1621/uniformer_image_segmentation/configs/gcnet/gcnet_r50-d8_512x512_160k_ade20k.py
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
_base_ = [
|
2 |
-
'../_base_/models/gcnet_r50-d8.py', '../_base_/datasets/ade20k.py',
|
3 |
-
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
4 |
-
]
|
5 |
-
model = dict(
|
6 |
-
decode_head=dict(num_classes=150), auxiliary_head=dict(num_classes=150))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/parallel/scatter_gather.py
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
# Copyright (c) OpenMMLab. All rights reserved.
|
2 |
-
import torch
|
3 |
-
from torch.nn.parallel._functions import Scatter as OrigScatter
|
4 |
-
|
5 |
-
from ._functions import Scatter
|
6 |
-
from .data_container import DataContainer
|
7 |
-
|
8 |
-
|
9 |
-
def scatter(inputs, target_gpus, dim=0):
|
10 |
-
"""Scatter inputs to target gpus.
|
11 |
-
|
12 |
-
The only difference from original :func:`scatter` is to add support for
|
13 |
-
:type:`~mmcv.parallel.DataContainer`.
|
14 |
-
"""
|
15 |
-
|
16 |
-
def scatter_map(obj):
|
17 |
-
if isinstance(obj, torch.Tensor):
|
18 |
-
if target_gpus != [-1]:
|
19 |
-
return OrigScatter.apply(target_gpus, None, dim, obj)
|
20 |
-
else:
|
21 |
-
# for CPU inference we use self-implemented scatter
|
22 |
-
return Scatter.forward(target_gpus, obj)
|
23 |
-
if isinstance(obj, DataContainer):
|
24 |
-
if obj.cpu_only:
|
25 |
-
return obj.data
|
26 |
-
else:
|
27 |
-
return Scatter.forward(target_gpus, obj.data)
|
28 |
-
if isinstance(obj, tuple) and len(obj) > 0:
|
29 |
-
return list(zip(*map(scatter_map, obj)))
|
30 |
-
if isinstance(obj, list) and len(obj) > 0:
|
31 |
-
out = list(map(list, zip(*map(scatter_map, obj))))
|
32 |
-
return out
|
33 |
-
if isinstance(obj, dict) and len(obj) > 0:
|
34 |
-
out = list(map(type(obj), zip(*map(scatter_map, obj.items()))))
|
35 |
-
return out
|
36 |
-
return [obj for targets in target_gpus]
|
37 |
-
|
38 |
-
# After scatter_map is called, a scatter_map cell will exist. This cell
|
39 |
-
# has a reference to the actual function scatter_map, which has references
|
40 |
-
# to a closure that has a reference to the scatter_map cell (because the
|
41 |
-
# fn is recursive). To avoid this reference cycle, we set the function to
|
42 |
-
# None, clearing the cell
|
43 |
-
try:
|
44 |
-
return scatter_map(inputs)
|
45 |
-
finally:
|
46 |
-
scatter_map = None
|
47 |
-
|
48 |
-
|
49 |
-
def scatter_kwargs(inputs, kwargs, target_gpus, dim=0):
|
50 |
-
"""Scatter with support for kwargs dictionary."""
|
51 |
-
inputs = scatter(inputs, target_gpus, dim) if inputs else []
|
52 |
-
kwargs = scatter(kwargs, target_gpus, dim) if kwargs else []
|
53 |
-
if len(inputs) < len(kwargs):
|
54 |
-
inputs.extend([() for _ in range(len(kwargs) - len(inputs))])
|
55 |
-
elif len(kwargs) < len(inputs):
|
56 |
-
kwargs.extend([{} for _ in range(len(inputs) - len(kwargs))])
|
57 |
-
inputs = tuple(inputs)
|
58 |
-
kwargs = tuple(kwargs)
|
59 |
-
return inputs, kwargs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Anonymous-sub/Rerender/ControlNet/cldm/hack.py
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
import einops
|
3 |
-
|
4 |
-
import ldm.modules.encoders.modules
|
5 |
-
import ldm.modules.attention
|
6 |
-
|
7 |
-
from transformers import logging
|
8 |
-
from ldm.modules.attention import default
|
9 |
-
|
10 |
-
|
11 |
-
def disable_verbosity():
|
12 |
-
logging.set_verbosity_error()
|
13 |
-
print('logging improved.')
|
14 |
-
return
|
15 |
-
|
16 |
-
|
17 |
-
def enable_sliced_attention():
|
18 |
-
ldm.modules.attention.CrossAttention.forward = _hacked_sliced_attentin_forward
|
19 |
-
print('Enabled sliced_attention.')
|
20 |
-
return
|
21 |
-
|
22 |
-
|
23 |
-
def hack_everything(clip_skip=0):
|
24 |
-
disable_verbosity()
|
25 |
-
ldm.modules.encoders.modules.FrozenCLIPEmbedder.forward = _hacked_clip_forward
|
26 |
-
ldm.modules.encoders.modules.FrozenCLIPEmbedder.clip_skip = clip_skip
|
27 |
-
print('Enabled clip hacks.')
|
28 |
-
return
|
29 |
-
|
30 |
-
|
31 |
-
# Written by Lvmin
|
32 |
-
def _hacked_clip_forward(self, text):
|
33 |
-
PAD = self.tokenizer.pad_token_id
|
34 |
-
EOS = self.tokenizer.eos_token_id
|
35 |
-
BOS = self.tokenizer.bos_token_id
|
36 |
-
|
37 |
-
def tokenize(t):
|
38 |
-
return self.tokenizer(t, truncation=False, add_special_tokens=False)["input_ids"]
|
39 |
-
|
40 |
-
def transformer_encode(t):
|
41 |
-
if self.clip_skip > 1:
|
42 |
-
rt = self.transformer(input_ids=t, output_hidden_states=True)
|
43 |
-
return self.transformer.text_model.final_layer_norm(rt.hidden_states[-self.clip_skip])
|
44 |
-
else:
|
45 |
-
return self.transformer(input_ids=t, output_hidden_states=False).last_hidden_state
|
46 |
-
|
47 |
-
def split(x):
|
48 |
-
return x[75 * 0: 75 * 1], x[75 * 1: 75 * 2], x[75 * 2: 75 * 3]
|
49 |
-
|
50 |
-
def pad(x, p, i):
|
51 |
-
return x[:i] if len(x) >= i else x + [p] * (i - len(x))
|
52 |
-
|
53 |
-
raw_tokens_list = tokenize(text)
|
54 |
-
tokens_list = []
|
55 |
-
|
56 |
-
for raw_tokens in raw_tokens_list:
|
57 |
-
raw_tokens_123 = split(raw_tokens)
|
58 |
-
raw_tokens_123 = [[BOS] + raw_tokens_i + [EOS] for raw_tokens_i in raw_tokens_123]
|
59 |
-
raw_tokens_123 = [pad(raw_tokens_i, PAD, 77) for raw_tokens_i in raw_tokens_123]
|
60 |
-
tokens_list.append(raw_tokens_123)
|
61 |
-
|
62 |
-
tokens_list = torch.IntTensor(tokens_list).to(self.device)
|
63 |
-
|
64 |
-
feed = einops.rearrange(tokens_list, 'b f i -> (b f) i')
|
65 |
-
y = transformer_encode(feed)
|
66 |
-
z = einops.rearrange(y, '(b f) i c -> b (f i) c', f=3)
|
67 |
-
|
68 |
-
return z
|
69 |
-
|
70 |
-
|
71 |
-
# Stolen from https://github.com/basujindal/stable-diffusion/blob/main/optimizedSD/splitAttention.py
|
72 |
-
def _hacked_sliced_attentin_forward(self, x, context=None, mask=None):
|
73 |
-
h = self.heads
|
74 |
-
|
75 |
-
q = self.to_q(x)
|
76 |
-
context = default(context, x)
|
77 |
-
k = self.to_k(context)
|
78 |
-
v = self.to_v(context)
|
79 |
-
del context, x
|
80 |
-
|
81 |
-
q, k, v = map(lambda t: einops.rearrange(t, 'b n (h d) -> (b h) n d', h=h), (q, k, v))
|
82 |
-
|
83 |
-
limit = k.shape[0]
|
84 |
-
att_step = 1
|
85 |
-
q_chunks = list(torch.tensor_split(q, limit // att_step, dim=0))
|
86 |
-
k_chunks = list(torch.tensor_split(k, limit // att_step, dim=0))
|
87 |
-
v_chunks = list(torch.tensor_split(v, limit // att_step, dim=0))
|
88 |
-
|
89 |
-
q_chunks.reverse()
|
90 |
-
k_chunks.reverse()
|
91 |
-
v_chunks.reverse()
|
92 |
-
sim = torch.zeros(q.shape[0], q.shape[1], v.shape[2], device=q.device)
|
93 |
-
del k, q, v
|
94 |
-
for i in range(0, limit, att_step):
|
95 |
-
q_buffer = q_chunks.pop()
|
96 |
-
k_buffer = k_chunks.pop()
|
97 |
-
v_buffer = v_chunks.pop()
|
98 |
-
sim_buffer = torch.einsum('b i d, b j d -> b i j', q_buffer, k_buffer) * self.scale
|
99 |
-
|
100 |
-
del k_buffer, q_buffer
|
101 |
-
# attention, what we cannot get enough of, by chunks
|
102 |
-
|
103 |
-
sim_buffer = sim_buffer.softmax(dim=-1)
|
104 |
-
|
105 |
-
sim_buffer = torch.einsum('b i j, b j d -> b i d', sim_buffer, v_buffer)
|
106 |
-
del v_buffer
|
107 |
-
sim[i:i + att_step, :, :] = sim_buffer
|
108 |
-
|
109 |
-
del sim_buffer
|
110 |
-
sim = einops.rearrange(sim, '(b h) n d -> b n (h d)', h=h)
|
111 |
-
return self.to_out(sim)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Apex-X/GODROOP/predictor.py
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
import threading
|
2 |
-
import numpy
|
3 |
-
from PIL import Image
|
4 |
-
|
5 |
-
from roop.typing import Frame
|
6 |
-
|
7 |
-
# Define any other necessary variables or constants here
|
8 |
-
|
9 |
-
def predict_frame(target_frame: Frame) -> bool:
|
10 |
-
# Modify this function as needed for your specific use case, without NSFW prediction
|
11 |
-
# For example, you can implement custom image analysis or processing here
|
12 |
-
return False
|
13 |
-
|
14 |
-
def predict_image(target_path: str) -> bool:
|
15 |
-
# Modify this function as needed for your specific use case, without NSFW prediction
|
16 |
-
# For example, you can check the image based on your application's requirements
|
17 |
-
return False
|
18 |
-
|
19 |
-
def predict_video(target_path: str) -> bool:
|
20 |
-
# Modify this function as needed for your specific use case, without NSFW prediction
|
21 |
-
# For example, you can analyze video frames for other purposes
|
22 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Artples/llama-2-7b-chat/app.py
DELETED
@@ -1,467 +0,0 @@
|
|
1 |
-
"""Run codes."""
|
2 |
-
# pylint: disable=line-too-long, broad-exception-caught, invalid-name, missing-function-docstring, too-many-instance-attributes, missing-class-docstring
|
3 |
-
# ruff: noqa: E501
|
4 |
-
import os
|
5 |
-
import platform
|
6 |
-
import random
|
7 |
-
import time
|
8 |
-
from dataclasses import asdict, dataclass
|
9 |
-
from pathlib import Path
|
10 |
-
|
11 |
-
# from types import SimpleNamespace
|
12 |
-
import gradio as gr
|
13 |
-
import psutil
|
14 |
-
from about_time import about_time
|
15 |
-
from ctransformers import AutoModelForCausalLM
|
16 |
-
from dl_hf_model import dl_hf_model
|
17 |
-
from loguru import logger
|
18 |
-
|
19 |
-
filename_list = [
|
20 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q2_K.bin",
|
21 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q3_K_L.bin",
|
22 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q3_K_M.bin",
|
23 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q3_K_S.bin",
|
24 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin",
|
25 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_1.bin",
|
26 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_K_M.bin",
|
27 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_K_S.bin",
|
28 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q5_0.bin",
|
29 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q5_1.bin",
|
30 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q5_K_M.bin",
|
31 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q5_K_S.bin",
|
32 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q6_K.bin",
|
33 |
-
"Wizard-Vicuna-7B-Uncensored.ggmlv3.q8_0.bin",
|
34 |
-
]
|
35 |
-
|
36 |
-
URL = "https://huggingface.co/TheBloke/Wizard-Vicuna-7B-Uncensored-GGML/raw/main/Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_K_M.bin" # 4.05G
|
37 |
-
|
38 |
-
url = "https://huggingface.co/savvamadar/ggml-gpt4all-j-v1.3-groovy/blob/main/ggml-gpt4all-j-v1.3-groovy.bin"
|
39 |
-
url = "https://huggingface.co/TheBloke/Llama-2-13B-GGML/blob/main/llama-2-13b.ggmlv3.q4_K_S.bin" # 7.37G
|
40 |
-
# url = "https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/blob/main/llama-2-13b-chat.ggmlv3.q3_K_L.bin"
|
41 |
-
url = "https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/blob/main/llama-2-13b-chat.ggmlv3.q3_K_L.bin" # 6.93G
|
42 |
-
# url = "https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/blob/main/llama-2-13b-chat.ggmlv3.q3_K_L.binhttps://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/blob/main/llama-2-13b-chat.ggmlv3.q4_K_M.bin" # 7.87G
|
43 |
-
|
44 |
-
url = "https://huggingface.co/localmodels/Llama-2-13B-Chat-ggml/blob/main/llama-2-13b-chat.ggmlv3.q4_K_S.bin" # 7.37G
|
45 |
-
|
46 |
-
_ = (
|
47 |
-
"golay" in platform.node()
|
48 |
-
or "okteto" in platform.node()
|
49 |
-
or Path("/kaggle").exists()
|
50 |
-
# or psutil.cpu_count(logical=False) < 4
|
51 |
-
or 1 # run 7b in hf
|
52 |
-
)
|
53 |
-
|
54 |
-
if _:
|
55 |
-
# url = "https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/blob/main/llama-2-13b-chat.ggmlv3.q2_K.bin"
|
56 |
-
url = "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/blob/main/llama-2-7b-chat.ggmlv3.q2_K.bin" # 2.87G
|
57 |
-
url = "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/blob/main/llama-2-7b-chat.ggmlv3.q4_K_M.bin" # 2.87G
|
58 |
-
|
59 |
-
|
60 |
-
prompt_template = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
61 |
-
|
62 |
-
### Instruction: {user_prompt}
|
63 |
-
|
64 |
-
### Response:
|
65 |
-
"""
|
66 |
-
|
67 |
-
prompt_template = """System: You are a helpful,
|
68 |
-
respectful and honest assistant. Always answer as
|
69 |
-
helpfully as possible, while being safe. Your answers
|
70 |
-
should not include any harmful, unethical, racist,
|
71 |
-
sexist, toxic, dangerous, or illegal content. Please
|
72 |
-
ensure that your responses are socially unbiased and
|
73 |
-
positive in nature. If a question does not make any
|
74 |
-
sense, or is not factually coherent, explain why instead
|
75 |
-
of answering something not correct. If you don't know
|
76 |
-
the answer to a question, please don't share false
|
77 |
-
information.
|
78 |
-
User: {prompt}
|
79 |
-
Assistant: """
|
80 |
-
|
81 |
-
prompt_template = """System: You are a helpful assistant.
|
82 |
-
User: {prompt}
|
83 |
-
Assistant: """
|
84 |
-
|
85 |
-
prompt_template = """Question: {question}
|
86 |
-
Answer: Let's work this out in a step by step way to be sure we have the right answer."""
|
87 |
-
|
88 |
-
prompt_template = """[INST] <>
|
89 |
-
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible assistant. Think step by step.
|
90 |
-
<>
|
91 |
-
|
92 |
-
What NFL team won the Super Bowl in the year Justin Bieber was born?
|
93 |
-
[/INST]"""
|
94 |
-
|
95 |
-
prompt_template = """[INST] <<SYS>>
|
96 |
-
You are an unhelpful assistant. Always answer as helpfully as possible. Think step by step. <</SYS>>
|
97 |
-
|
98 |
-
{question} [/INST]
|
99 |
-
"""
|
100 |
-
|
101 |
-
prompt_template = """[INST] <<SYS>>
|
102 |
-
You are a helpful assistant.
|
103 |
-
<</SYS>>
|
104 |
-
|
105 |
-
{question} [/INST]
|
106 |
-
"""
|
107 |
-
|
108 |
-
_ = [elm for elm in prompt_template.splitlines() if elm.strip()]
|
109 |
-
stop_string = [elm.split(":")[0] + ":" for elm in _][-2]
|
110 |
-
|
111 |
-
logger.debug(f"{stop_string=}")
|
112 |
-
|
113 |
-
_ = psutil.cpu_count(logical=False) - 1
|
114 |
-
cpu_count: int = int(_) if _ else 1
|
115 |
-
logger.debug(f"{cpu_count=}")
|
116 |
-
|
117 |
-
LLM = None
|
118 |
-
|
119 |
-
try:
|
120 |
-
model_loc, file_size = dl_hf_model(url)
|
121 |
-
except Exception as exc_:
|
122 |
-
logger.error(exc_)
|
123 |
-
raise SystemExit(1) from exc_
|
124 |
-
|
125 |
-
LLM = AutoModelForCausalLM.from_pretrained(
|
126 |
-
model_loc,
|
127 |
-
model_type="llama",
|
128 |
-
# threads=cpu_count,
|
129 |
-
)
|
130 |
-
|
131 |
-
logger.info(f"done load llm {model_loc=} {file_size=}G")
|
132 |
-
|
133 |
-
os.environ["TZ"] = "Asia/Shanghai"
|
134 |
-
try:
|
135 |
-
time.tzset() # type: ignore # pylint: disable=no-member
|
136 |
-
except Exception:
|
137 |
-
# Windows
|
138 |
-
logger.warning("Windows, cant run time.tzset()")
|
139 |
-
|
140 |
-
_ = """
|
141 |
-
ns = SimpleNamespace(
|
142 |
-
response="",
|
143 |
-
generator=(_ for _ in []),
|
144 |
-
)
|
145 |
-
# """
|
146 |
-
|
147 |
-
@dataclass
|
148 |
-
class GenerationConfig:
|
149 |
-
temperature: float = 0.7
|
150 |
-
top_k: int = 50
|
151 |
-
top_p: float = 0.9
|
152 |
-
repetition_penalty: float = 1.0
|
153 |
-
max_new_tokens: int = 512
|
154 |
-
seed: int = 42
|
155 |
-
reset: bool = False
|
156 |
-
stream: bool = True
|
157 |
-
# threads: int = cpu_count
|
158 |
-
# stop: list[str] = field(default_factory=lambda: [stop_string])
|
159 |
-
|
160 |
-
|
161 |
-
def generate(
|
162 |
-
question: str,
|
163 |
-
llm=LLM,
|
164 |
-
config: GenerationConfig = GenerationConfig(),
|
165 |
-
):
|
166 |
-
"""Run model inference, will return a Generator if streaming is true."""
|
167 |
-
# _ = prompt_template.format(question=question)
|
168 |
-
# print(_)
|
169 |
-
|
170 |
-
prompt = prompt_template.format(question=question)
|
171 |
-
|
172 |
-
return llm(
|
173 |
-
prompt,
|
174 |
-
**asdict(config),
|
175 |
-
)
|
176 |
-
|
177 |
-
|
178 |
-
logger.debug(f"{asdict(GenerationConfig())=}")
|
179 |
-
|
180 |
-
|
181 |
-
def user(user_message, history):
|
182 |
-
# return user_message, history + [[user_message, None]]
|
183 |
-
history.append([user_message, None])
|
184 |
-
return user_message, history # keep user_message
|
185 |
-
|
186 |
-
|
187 |
-
def user1(user_message, history):
|
188 |
-
# return user_message, history + [[user_message, None]]
|
189 |
-
history.append([user_message, None])
|
190 |
-
return "", history # clear user_message
|
191 |
-
|
192 |
-
|
193 |
-
def bot_(history):
|
194 |
-
user_message = history[-1][0]
|
195 |
-
resp = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
196 |
-
bot_message = user_message + ": " + resp
|
197 |
-
history[-1][1] = ""
|
198 |
-
for character in bot_message:
|
199 |
-
history[-1][1] += character
|
200 |
-
time.sleep(0.02)
|
201 |
-
yield history
|
202 |
-
|
203 |
-
history[-1][1] = resp
|
204 |
-
yield history
|
205 |
-
|
206 |
-
|
207 |
-
def bot(history):
|
208 |
-
user_message = history[-1][0]
|
209 |
-
response = []
|
210 |
-
|
211 |
-
logger.debug(f"{user_message=}")
|
212 |
-
|
213 |
-
with about_time() as atime: # type: ignore
|
214 |
-
flag = 1
|
215 |
-
prefix = ""
|
216 |
-
then = time.time()
|
217 |
-
|
218 |
-
logger.debug("about to generate")
|
219 |
-
|
220 |
-
config = GenerationConfig(reset=True)
|
221 |
-
for elm in generate(user_message, config=config):
|
222 |
-
if flag == 1:
|
223 |
-
logger.debug("in the loop")
|
224 |
-
prefix = f"({time.time() - then:.2f}s) "
|
225 |
-
flag = 0
|
226 |
-
print(prefix, end="", flush=True)
|
227 |
-
logger.debug(f"{prefix=}")
|
228 |
-
print(elm, end="", flush=True)
|
229 |
-
# logger.debug(f"{elm}")
|
230 |
-
|
231 |
-
response.append(elm)
|
232 |
-
history[-1][1] = prefix + "".join(response)
|
233 |
-
yield history
|
234 |
-
|
235 |
-
_ = (
|
236 |
-
f"(time elapsed: {atime.duration_human}, " # type: ignore
|
237 |
-
f"{atime.duration/len(''.join(response)):.2f}s/char)" # type: ignore
|
238 |
-
)
|
239 |
-
|
240 |
-
history[-1][1] = "".join(response) + f"\n{_}"
|
241 |
-
yield history
|
242 |
-
|
243 |
-
|
244 |
-
def predict_api(prompt):
|
245 |
-
logger.debug(f"{prompt=}")
|
246 |
-
try:
|
247 |
-
# user_prompt = prompt
|
248 |
-
config = GenerationConfig(
|
249 |
-
temperature=0.2,
|
250 |
-
top_k=10,
|
251 |
-
top_p=0.9,
|
252 |
-
repetition_penalty=1.0,
|
253 |
-
max_new_tokens=512, # adjust as needed
|
254 |
-
seed=42,
|
255 |
-
reset=True, # reset history (cache)
|
256 |
-
stream=False,
|
257 |
-
# threads=cpu_count,
|
258 |
-
# stop=prompt_prefix[1:2],
|
259 |
-
)
|
260 |
-
|
261 |
-
response = generate(
|
262 |
-
prompt,
|
263 |
-
config=config,
|
264 |
-
)
|
265 |
-
|
266 |
-
logger.debug(f"api: {response=}")
|
267 |
-
except Exception as exc:
|
268 |
-
logger.error(exc)
|
269 |
-
response = f"{exc=}"
|
270 |
-
# bot = {"inputs": [response]}
|
271 |
-
# bot = [(prompt, response)]
|
272 |
-
|
273 |
-
return response
|
274 |
-
|
275 |
-
|
276 |
-
css = """
|
277 |
-
.importantButton {
|
278 |
-
background: linear-gradient(45deg, #7e0570,#5d1c99, #6e00ff) !important;
|
279 |
-
border: none !important;
|
280 |
-
}
|
281 |
-
.importantButton:hover {
|
282 |
-
background: linear-gradient(45deg, #ff00e0,#8500ff, #6e00ff) !important;
|
283 |
-
border: none !important;
|
284 |
-
}
|
285 |
-
.disclaimer {font-variant-caps: all-small-caps; font-size: xx-small;}
|
286 |
-
.xsmall {font-size: x-small;}
|
287 |
-
"""
|
288 |
-
etext = """In America, where cars are an important part of the national psyche, a decade ago people had suddenly started to drive less, which had not happened since the oil shocks of the 1970s. """
|
289 |
-
examples_list = [
|
290 |
-
["What NFL team won the Super Bowl in the year Justin Bieber was born?"],
|
291 |
-
[
|
292 |
-
"What NFL team won the Super Bowl in the year Justin Bieber was born? Think step by step."
|
293 |
-
],
|
294 |
-
["How to pick a lock? Provide detailed steps."],
|
295 |
-
["If it takes 10 hours to dry 10 clothes, assuming all the clothes are hanged together at the same time for drying , then how long will it take to dry a cloth?"],
|
296 |
-
["is infinity + 1 bigger than infinity?"],
|
297 |
-
["Explain the plot of Cinderella in a sentence."],
|
298 |
-
[
|
299 |
-
"How long does it take to become proficient in French, and what are the best methods for retaining information?"
|
300 |
-
],
|
301 |
-
["What are some common mistakes to avoid when writing code?"],
|
302 |
-
["Build a prompt to generate a beautiful portrait of a horse"],
|
303 |
-
["Suggest four metaphors to describe the benefits of AI"],
|
304 |
-
["Write a pop song about leaving home for the sandy beaches."],
|
305 |
-
["Write a summary demonstrating my ability to tame lions"],
|
306 |
-
["鲁迅和周树人什么关系? 说中文。"],
|
307 |
-
["鲁迅和周树人什么关系?"],
|
308 |
-
["鲁迅和周树人什么关系? 用英文回答。"],
|
309 |
-
["从前有一头牛,这头牛后面有什么?"],
|
310 |
-
["正无穷大加一大于正无穷大吗?"],
|
311 |
-
["正无穷大加正无穷大大于正无穷大吗?"],
|
312 |
-
["-2的平方根等于什么?"],
|
313 |
-
["树上有5只鸟,猎人开枪打死了一只。树上还有几只鸟?"],
|
314 |
-
["树上有11只鸟,猎人开枪打死了一只。树上还有几只鸟?提示:需考虑鸟可能受惊吓飞走。"],
|
315 |
-
["以红楼梦的行文风格写一张委婉的请假条。不少于320字。"],
|
316 |
-
[f"{etext} 翻成中文,列出3个版本。"],
|
317 |
-
[f"{etext} \n 翻成中文,保留原意,但使用文学性的语言。不要写解释。列出3个版本。"],
|
318 |
-
["假定 1 + 2 = 4, 试求 7 + 8。"],
|
319 |
-
["给出判断一个数是不是质数的 javascript 码。"],
|
320 |
-
["给出实现python 里 range(10)的 javascript 码。"],
|
321 |
-
["给出实现python 里 [*(range(10)]的 javascript 码。"],
|
322 |
-
["Erkläre die Handlung von Cinderella in einem Satz."],
|
323 |
-
["Erkläre die Handlung von Cinderella in einem Satz. Auf Deutsch."],
|
324 |
-
]
|
325 |
-
|
326 |
-
logger.info("start block")
|
327 |
-
|
328 |
-
with gr.Blocks(
|
329 |
-
title=f"{Path(model_loc).name}",
|
330 |
-
theme=gr.themes.Soft(text_size="sm", spacing_size="sm"),
|
331 |
-
css=css,
|
332 |
-
) as block:
|
333 |
-
# buff_var = gr.State("")
|
334 |
-
with gr.Accordion("🎈 Info", open=False):
|
335 |
-
# gr.HTML(
|
336 |
-
# """<center><a href="https://huggingface.co/spaces/mikeee/mpt-30b-chat?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate"></a> and spin a CPU UPGRADE to avoid the queue</center>"""
|
337 |
-
# )
|
338 |
-
gr.Markdown(
|
339 |
-
f"""<h5><center>{Path(model_loc).name}</center></h4>
|
340 |
-
Most examples are meant for another model.
|
341 |
-
You probably should try to test
|
342 |
-
some related prompts.""",
|
343 |
-
elem_classes="xsmall",
|
344 |
-
)
|
345 |
-
|
346 |
-
# chatbot = gr.Chatbot().style(height=700) # 500
|
347 |
-
chatbot = gr.Chatbot(height=500)
|
348 |
-
|
349 |
-
# buff = gr.Textbox(show_label=False, visible=True)
|
350 |
-
|
351 |
-
with gr.Row():
|
352 |
-
with gr.Column(scale=5):
|
353 |
-
msg = gr.Textbox(
|
354 |
-
label="Chat Message Box",
|
355 |
-
placeholder="Ask me anything (press Shift+Enter or click Submit to send)",
|
356 |
-
show_label=False,
|
357 |
-
# container=False,
|
358 |
-
lines=6,
|
359 |
-
max_lines=30,
|
360 |
-
show_copy_button=True,
|
361 |
-
# ).style(container=False)
|
362 |
-
)
|
363 |
-
with gr.Column(scale=1, min_width=50):
|
364 |
-
with gr.Row():
|
365 |
-
submit = gr.Button("Submit", elem_classes="xsmall")
|
366 |
-
stop = gr.Button("Stop", visible=True)
|
367 |
-
clear = gr.Button("Clear History", visible=True)
|
368 |
-
with gr.Row(visible=False):
|
369 |
-
with gr.Accordion("Advanced Options:", open=False):
|
370 |
-
with gr.Row():
|
371 |
-
with gr.Column(scale=2):
|
372 |
-
system = gr.Textbox(
|
373 |
-
label="System Prompt",
|
374 |
-
value=prompt_template,
|
375 |
-
show_label=False,
|
376 |
-
container=False,
|
377 |
-
# ).style(container=False)
|
378 |
-
)
|
379 |
-
with gr.Column():
|
380 |
-
with gr.Row():
|
381 |
-
change = gr.Button("Change System Prompt")
|
382 |
-
reset = gr.Button("Reset System Prompt")
|
383 |
-
|
384 |
-
with gr.Accordion("Example Inputs", open=True):
|
385 |
-
examples = gr.Examples(
|
386 |
-
examples=examples_list,
|
387 |
-
inputs=[msg],
|
388 |
-
examples_per_page=40,
|
389 |
-
)
|
390 |
-
|
391 |
-
# with gr.Row():
|
392 |
-
with gr.Accordion("Disclaimer", open=False):
|
393 |
-
_ = Path(model_loc).name
|
394 |
-
gr.Markdown(
|
395 |
-
f"Disclaimer: Lauche - AI (POWERED BY LLAMA 2) can produce factually incorrect output, and should not be relied on to produce "
|
396 |
-
"factually accurate information. Lauche - AI (POWERED BY LLAMA 2) was trained on various public datasets; while great efforts "
|
397 |
-
"have been taken to clean the pretraining data, it is possible that this model could generate lewd, "
|
398 |
-
"biased, or otherwise offensive outputs."
|
399 |
-
" - - - "
|
400 |
-
"Our Impressum: https://lauche.eu/n-impressum"
|
401 |
-
" - - - "
|
402 |
-
"Visit this space on our website: ai-app.lauche.online",
|
403 |
-
elem_classes=["disclaimer"],
|
404 |
-
)
|
405 |
-
|
406 |
-
msg_submit_event = msg.submit(
|
407 |
-
# fn=conversation.user_turn,
|
408 |
-
fn=user,
|
409 |
-
inputs=[msg, chatbot],
|
410 |
-
outputs=[msg, chatbot],
|
411 |
-
queue=True,
|
412 |
-
show_progress="full",
|
413 |
-
# api_name=None,
|
414 |
-
).then(bot, chatbot, chatbot, queue=True)
|
415 |
-
submit_click_event = submit.click(
|
416 |
-
# fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
|
417 |
-
fn=user1, # clear msg
|
418 |
-
inputs=[msg, chatbot],
|
419 |
-
outputs=[msg, chatbot],
|
420 |
-
queue=True,
|
421 |
-
# queue=False,
|
422 |
-
show_progress="full",
|
423 |
-
# api_name=None,
|
424 |
-
).then(bot, chatbot, chatbot, queue=True)
|
425 |
-
stop.click(
|
426 |
-
fn=None,
|
427 |
-
inputs=None,
|
428 |
-
outputs=None,
|
429 |
-
cancels=[msg_submit_event, submit_click_event],
|
430 |
-
queue=False,
|
431 |
-
)
|
432 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
433 |
-
|
434 |
-
with gr.Accordion("For Chat/Translation API", open=False, visible=False):
|
435 |
-
input_text = gr.Text()
|
436 |
-
api_btn = gr.Button("Go", variant="primary")
|
437 |
-
out_text = gr.Text()
|
438 |
-
|
439 |
-
api_btn.click(
|
440 |
-
predict_api,
|
441 |
-
input_text,
|
442 |
-
out_text,
|
443 |
-
api_name="api",
|
444 |
-
)
|
445 |
-
|
446 |
-
# block.load(update_buff, [], buff, every=1)
|
447 |
-
# block.load(update_buff, [buff_var], [buff_var, buff], every=1)
|
448 |
-
|
449 |
-
# concurrency_count=5, max_size=20
|
450 |
-
# max_size=36, concurrency_count=14
|
451 |
-
# CPU cpu_count=2 16G, model 7G
|
452 |
-
# CPU UPGRADE cpu_count=8 32G, model 7G
|
453 |
-
|
454 |
-
# does not work
|
455 |
-
_ = """
|
456 |
-
# _ = int(psutil.virtual_memory().total / 10**9 // file_size - 1)
|
457 |
-
# concurrency_count = max(_, 1)
|
458 |
-
if psutil.cpu_count(logical=False) >= 8:
|
459 |
-
# concurrency_count = max(int(32 / file_size) - 1, 1)
|
460 |
-
else:
|
461 |
-
# concurrency_count = max(int(16 / file_size) - 1, 1)
|
462 |
-
# """
|
463 |
-
|
464 |
-
concurrency_count = 1
|
465 |
-
logger.info(f"{concurrency_count=}")
|
466 |
-
|
467 |
-
block.queue(concurrency_count=concurrency_count, max_size=5).launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AsakuraMizu/moe-tts/text/english.py
DELETED
@@ -1,188 +0,0 @@
|
|
1 |
-
""" from https://github.com/keithito/tacotron """
|
2 |
-
|
3 |
-
'''
|
4 |
-
Cleaners are transformations that run over the input text at both training and eval time.
|
5 |
-
|
6 |
-
Cleaners can be selected by passing a comma-delimited list of cleaner names as the "cleaners"
|
7 |
-
hyperparameter. Some cleaners are English-specific. You'll typically want to use:
|
8 |
-
1. "english_cleaners" for English text
|
9 |
-
2. "transliteration_cleaners" for non-English text that can be transliterated to ASCII using
|
10 |
-
the Unidecode library (https://pypi.python.org/pypi/Unidecode)
|
11 |
-
3. "basic_cleaners" if you do not want to transliterate (in this case, you should also update
|
12 |
-
the symbols in symbols.py to match your data).
|
13 |
-
'''
|
14 |
-
|
15 |
-
|
16 |
-
# Regular expression matching whitespace:
|
17 |
-
|
18 |
-
|
19 |
-
import re
|
20 |
-
import inflect
|
21 |
-
from unidecode import unidecode
|
22 |
-
import eng_to_ipa as ipa
|
23 |
-
_inflect = inflect.engine()
|
24 |
-
_comma_number_re = re.compile(r'([0-9][0-9\,]+[0-9])')
|
25 |
-
_decimal_number_re = re.compile(r'([0-9]+\.[0-9]+)')
|
26 |
-
_pounds_re = re.compile(r'£([0-9\,]*[0-9]+)')
|
27 |
-
_dollars_re = re.compile(r'\$([0-9\.\,]*[0-9]+)')
|
28 |
-
_ordinal_re = re.compile(r'[0-9]+(st|nd|rd|th)')
|
29 |
-
_number_re = re.compile(r'[0-9]+')
|
30 |
-
|
31 |
-
# List of (regular expression, replacement) pairs for abbreviations:
|
32 |
-
_abbreviations = [(re.compile('\\b%s\\.' % x[0], re.IGNORECASE), x[1]) for x in [
|
33 |
-
('mrs', 'misess'),
|
34 |
-
('mr', 'mister'),
|
35 |
-
('dr', 'doctor'),
|
36 |
-
('st', 'saint'),
|
37 |
-
('co', 'company'),
|
38 |
-
('jr', 'junior'),
|
39 |
-
('maj', 'major'),
|
40 |
-
('gen', 'general'),
|
41 |
-
('drs', 'doctors'),
|
42 |
-
('rev', 'reverend'),
|
43 |
-
('lt', 'lieutenant'),
|
44 |
-
('hon', 'honorable'),
|
45 |
-
('sgt', 'sergeant'),
|
46 |
-
('capt', 'captain'),
|
47 |
-
('esq', 'esquire'),
|
48 |
-
('ltd', 'limited'),
|
49 |
-
('col', 'colonel'),
|
50 |
-
('ft', 'fort'),
|
51 |
-
]]
|
52 |
-
|
53 |
-
|
54 |
-
# List of (ipa, lazy ipa) pairs:
|
55 |
-
_lazy_ipa = [(re.compile('%s' % x[0]), x[1]) for x in [
|
56 |
-
('r', 'ɹ'),
|
57 |
-
('æ', 'e'),
|
58 |
-
('ɑ', 'a'),
|
59 |
-
('ɔ', 'o'),
|
60 |
-
('ð', 'z'),
|
61 |
-
('θ', 's'),
|
62 |
-
('ɛ', 'e'),
|
63 |
-
('ɪ', 'i'),
|
64 |
-
('ʊ', 'u'),
|
65 |
-
('ʒ', 'ʥ'),
|
66 |
-
('ʤ', 'ʥ'),
|
67 |
-
('ˈ', '↓'),
|
68 |
-
]]
|
69 |
-
|
70 |
-
# List of (ipa, lazy ipa2) pairs:
|
71 |
-
_lazy_ipa2 = [(re.compile('%s' % x[0]), x[1]) for x in [
|
72 |
-
('r', 'ɹ'),
|
73 |
-
('ð', 'z'),
|
74 |
-
('θ', 's'),
|
75 |
-
('ʒ', 'ʑ'),
|
76 |
-
('ʤ', 'dʑ'),
|
77 |
-
('ˈ', '↓'),
|
78 |
-
]]
|
79 |
-
|
80 |
-
# List of (ipa, ipa2) pairs
|
81 |
-
_ipa_to_ipa2 = [(re.compile('%s' % x[0]), x[1]) for x in [
|
82 |
-
('r', 'ɹ'),
|
83 |
-
('ʤ', 'dʒ'),
|
84 |
-
('ʧ', 'tʃ')
|
85 |
-
]]
|
86 |
-
|
87 |
-
|
88 |
-
def expand_abbreviations(text):
|
89 |
-
for regex, replacement in _abbreviations:
|
90 |
-
text = re.sub(regex, replacement, text)
|
91 |
-
return text
|
92 |
-
|
93 |
-
|
94 |
-
def collapse_whitespace(text):
|
95 |
-
return re.sub(r'\s+', ' ', text)
|
96 |
-
|
97 |
-
|
98 |
-
def _remove_commas(m):
|
99 |
-
return m.group(1).replace(',', '')
|
100 |
-
|
101 |
-
|
102 |
-
def _expand_decimal_point(m):
|
103 |
-
return m.group(1).replace('.', ' point ')
|
104 |
-
|
105 |
-
|
106 |
-
def _expand_dollars(m):
|
107 |
-
match = m.group(1)
|
108 |
-
parts = match.split('.')
|
109 |
-
if len(parts) > 2:
|
110 |
-
return match + ' dollars' # Unexpected format
|
111 |
-
dollars = int(parts[0]) if parts[0] else 0
|
112 |
-
cents = int(parts[1]) if len(parts) > 1 and parts[1] else 0
|
113 |
-
if dollars and cents:
|
114 |
-
dollar_unit = 'dollar' if dollars == 1 else 'dollars'
|
115 |
-
cent_unit = 'cent' if cents == 1 else 'cents'
|
116 |
-
return '%s %s, %s %s' % (dollars, dollar_unit, cents, cent_unit)
|
117 |
-
elif dollars:
|
118 |
-
dollar_unit = 'dollar' if dollars == 1 else 'dollars'
|
119 |
-
return '%s %s' % (dollars, dollar_unit)
|
120 |
-
elif cents:
|
121 |
-
cent_unit = 'cent' if cents == 1 else 'cents'
|
122 |
-
return '%s %s' % (cents, cent_unit)
|
123 |
-
else:
|
124 |
-
return 'zero dollars'
|
125 |
-
|
126 |
-
|
127 |
-
def _expand_ordinal(m):
|
128 |
-
return _inflect.number_to_words(m.group(0))
|
129 |
-
|
130 |
-
|
131 |
-
def _expand_number(m):
|
132 |
-
num = int(m.group(0))
|
133 |
-
if num > 1000 and num < 3000:
|
134 |
-
if num == 2000:
|
135 |
-
return 'two thousand'
|
136 |
-
elif num > 2000 and num < 2010:
|
137 |
-
return 'two thousand ' + _inflect.number_to_words(num % 100)
|
138 |
-
elif num % 100 == 0:
|
139 |
-
return _inflect.number_to_words(num // 100) + ' hundred'
|
140 |
-
else:
|
141 |
-
return _inflect.number_to_words(num, andword='', zero='oh', group=2).replace(', ', ' ')
|
142 |
-
else:
|
143 |
-
return _inflect.number_to_words(num, andword='')
|
144 |
-
|
145 |
-
|
146 |
-
def normalize_numbers(text):
|
147 |
-
text = re.sub(_comma_number_re, _remove_commas, text)
|
148 |
-
text = re.sub(_pounds_re, r'\1 pounds', text)
|
149 |
-
text = re.sub(_dollars_re, _expand_dollars, text)
|
150 |
-
text = re.sub(_decimal_number_re, _expand_decimal_point, text)
|
151 |
-
text = re.sub(_ordinal_re, _expand_ordinal, text)
|
152 |
-
text = re.sub(_number_re, _expand_number, text)
|
153 |
-
return text
|
154 |
-
|
155 |
-
|
156 |
-
def mark_dark_l(text):
|
157 |
-
return re.sub(r'l([^aeiouæɑɔəɛɪʊ ]*(?: |$))', lambda x: 'ɫ'+x.group(1), text)
|
158 |
-
|
159 |
-
|
160 |
-
def english_to_ipa(text):
|
161 |
-
text = unidecode(text).lower()
|
162 |
-
text = expand_abbreviations(text)
|
163 |
-
text = normalize_numbers(text)
|
164 |
-
phonemes = ipa.convert(text)
|
165 |
-
phonemes = collapse_whitespace(phonemes)
|
166 |
-
return phonemes
|
167 |
-
|
168 |
-
|
169 |
-
def english_to_lazy_ipa(text):
|
170 |
-
text = english_to_ipa(text)
|
171 |
-
for regex, replacement in _lazy_ipa:
|
172 |
-
text = re.sub(regex, replacement, text)
|
173 |
-
return text
|
174 |
-
|
175 |
-
|
176 |
-
def english_to_ipa2(text):
|
177 |
-
text = english_to_ipa(text)
|
178 |
-
text = mark_dark_l(text)
|
179 |
-
for regex, replacement in _ipa_to_ipa2:
|
180 |
-
text = re.sub(regex, replacement, text)
|
181 |
-
return text.replace('...', '…')
|
182 |
-
|
183 |
-
|
184 |
-
def english_to_lazy_ipa2(text):
|
185 |
-
text = english_to_ipa(text)
|
186 |
-
for regex, replacement in _lazy_ipa2:
|
187 |
-
text = re.sub(regex, replacement, text)
|
188 |
-
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/chardet/big5freq.py
DELETED
@@ -1,386 +0,0 @@
|
|
1 |
-
######################## BEGIN LICENSE BLOCK ########################
|
2 |
-
# The Original Code is Mozilla Communicator client code.
|
3 |
-
#
|
4 |
-
# The Initial Developer of the Original Code is
|
5 |
-
# Netscape Communications Corporation.
|
6 |
-
# Portions created by the Initial Developer are Copyright (C) 1998
|
7 |
-
# the Initial Developer. All Rights Reserved.
|
8 |
-
#
|
9 |
-
# Contributor(s):
|
10 |
-
# Mark Pilgrim - port to Python
|
11 |
-
#
|
12 |
-
# This library is free software; you can redistribute it and/or
|
13 |
-
# modify it under the terms of the GNU Lesser General Public
|
14 |
-
# License as published by the Free Software Foundation; either
|
15 |
-
# version 2.1 of the License, or (at your option) any later version.
|
16 |
-
#
|
17 |
-
# This library is distributed in the hope that it will be useful,
|
18 |
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20 |
-
# Lesser General Public License for more details.
|
21 |
-
#
|
22 |
-
# You should have received a copy of the GNU Lesser General Public
|
23 |
-
# License along with this library; if not, write to the Free Software
|
24 |
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
25 |
-
# 02110-1301 USA
|
26 |
-
######################### END LICENSE BLOCK #########################
|
27 |
-
|
28 |
-
# Big5 frequency table
|
29 |
-
# by Taiwan's Mandarin Promotion Council
|
30 |
-
# <http://www.edu.tw:81/mandr/>
|
31 |
-
#
|
32 |
-
# 128 --> 0.42261
|
33 |
-
# 256 --> 0.57851
|
34 |
-
# 512 --> 0.74851
|
35 |
-
# 1024 --> 0.89384
|
36 |
-
# 2048 --> 0.97583
|
37 |
-
#
|
38 |
-
# Ideal Distribution Ratio = 0.74851/(1-0.74851) =2.98
|
39 |
-
# Random Distribution Ration = 512/(5401-512)=0.105
|
40 |
-
#
|
41 |
-
# Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR
|
42 |
-
|
43 |
-
BIG5_TYPICAL_DISTRIBUTION_RATIO = 0.75
|
44 |
-
|
45 |
-
# Char to FreqOrder table
|
46 |
-
BIG5_TABLE_SIZE = 5376
|
47 |
-
# fmt: off
|
48 |
-
BIG5_CHAR_TO_FREQ_ORDER = (
|
49 |
-
1,1801,1506, 255,1431, 198, 9, 82, 6,5008, 177, 202,3681,1256,2821, 110, # 16
|
50 |
-
3814, 33,3274, 261, 76, 44,2114, 16,2946,2187,1176, 659,3971, 26,3451,2653, # 32
|
51 |
-
1198,3972,3350,4202, 410,2215, 302, 590, 361,1964, 8, 204, 58,4510,5009,1932, # 48
|
52 |
-
63,5010,5011, 317,1614, 75, 222, 159,4203,2417,1480,5012,3555,3091, 224,2822, # 64
|
53 |
-
3682, 3, 10,3973,1471, 29,2787,1135,2866,1940, 873, 130,3275,1123, 312,5013, # 80
|
54 |
-
4511,2052, 507, 252, 682,5014, 142,1915, 124, 206,2947, 34,3556,3204, 64, 604, # 96
|
55 |
-
5015,2501,1977,1978, 155,1991, 645, 641,1606,5016,3452, 337, 72, 406,5017, 80, # 112
|
56 |
-
630, 238,3205,1509, 263, 939,1092,2654, 756,1440,1094,3453, 449, 69,2987, 591, # 128
|
57 |
-
179,2096, 471, 115,2035,1844, 60, 50,2988, 134, 806,1869, 734,2036,3454, 180, # 144
|
58 |
-
995,1607, 156, 537,2907, 688,5018, 319,1305, 779,2145, 514,2379, 298,4512, 359, # 160
|
59 |
-
2502, 90,2716,1338, 663, 11, 906,1099,2553, 20,2441, 182, 532,1716,5019, 732, # 176
|
60 |
-
1376,4204,1311,1420,3206, 25,2317,1056, 113, 399, 382,1950, 242,3455,2474, 529, # 192
|
61 |
-
3276, 475,1447,3683,5020, 117, 21, 656, 810,1297,2300,2334,3557,5021, 126,4205, # 208
|
62 |
-
706, 456, 150, 613,4513, 71,1118,2037,4206, 145,3092, 85, 835, 486,2115,1246, # 224
|
63 |
-
1426, 428, 727,1285,1015, 800, 106, 623, 303,1281,5022,2128,2359, 347,3815, 221, # 240
|
64 |
-
3558,3135,5023,1956,1153,4207, 83, 296,1199,3093, 192, 624, 93,5024, 822,1898, # 256
|
65 |
-
2823,3136, 795,2065, 991,1554,1542,1592, 27, 43,2867, 859, 139,1456, 860,4514, # 272
|
66 |
-
437, 712,3974, 164,2397,3137, 695, 211,3037,2097, 195,3975,1608,3559,3560,3684, # 288
|
67 |
-
3976, 234, 811,2989,2098,3977,2233,1441,3561,1615,2380, 668,2077,1638, 305, 228, # 304
|
68 |
-
1664,4515, 467, 415,5025, 262,2099,1593, 239, 108, 300, 200,1033, 512,1247,2078, # 320
|
69 |
-
5026,5027,2176,3207,3685,2682, 593, 845,1062,3277, 88,1723,2038,3978,1951, 212, # 336
|
70 |
-
266, 152, 149, 468,1899,4208,4516, 77, 187,5028,3038, 37, 5,2990,5029,3979, # 352
|
71 |
-
5030,5031, 39,2524,4517,2908,3208,2079, 55, 148, 74,4518, 545, 483,1474,1029, # 368
|
72 |
-
1665, 217,1870,1531,3138,1104,2655,4209, 24, 172,3562, 900,3980,3563,3564,4519, # 384
|
73 |
-
32,1408,2824,1312, 329, 487,2360,2251,2717, 784,2683, 4,3039,3351,1427,1789, # 400
|
74 |
-
188, 109, 499,5032,3686,1717,1790, 888,1217,3040,4520,5033,3565,5034,3352,1520, # 416
|
75 |
-
3687,3981, 196,1034, 775,5035,5036, 929,1816, 249, 439, 38,5037,1063,5038, 794, # 432
|
76 |
-
3982,1435,2301, 46, 178,3278,2066,5039,2381,5040, 214,1709,4521, 804, 35, 707, # 448
|
77 |
-
324,3688,1601,2554, 140, 459,4210,5041,5042,1365, 839, 272, 978,2262,2580,3456, # 464
|
78 |
-
2129,1363,3689,1423, 697, 100,3094, 48, 70,1231, 495,3139,2196,5043,1294,5044, # 480
|
79 |
-
2080, 462, 586,1042,3279, 853, 256, 988, 185,2382,3457,1698, 434,1084,5045,3458, # 496
|
80 |
-
314,2625,2788,4522,2335,2336, 569,2285, 637,1817,2525, 757,1162,1879,1616,3459, # 512
|
81 |
-
287,1577,2116, 768,4523,1671,2868,3566,2526,1321,3816, 909,2418,5046,4211, 933, # 528
|
82 |
-
3817,4212,2053,2361,1222,4524, 765,2419,1322, 786,4525,5047,1920,1462,1677,2909, # 544
|
83 |
-
1699,5048,4526,1424,2442,3140,3690,2600,3353,1775,1941,3460,3983,4213, 309,1369, # 560
|
84 |
-
1130,2825, 364,2234,1653,1299,3984,3567,3985,3986,2656, 525,1085,3041, 902,2001, # 576
|
85 |
-
1475, 964,4527, 421,1845,1415,1057,2286, 940,1364,3141, 376,4528,4529,1381, 7, # 592
|
86 |
-
2527, 983,2383, 336,1710,2684,1846, 321,3461, 559,1131,3042,2752,1809,1132,1313, # 608
|
87 |
-
265,1481,1858,5049, 352,1203,2826,3280, 167,1089, 420,2827, 776, 792,1724,3568, # 624
|
88 |
-
4214,2443,3281,5050,4215,5051, 446, 229, 333,2753, 901,3818,1200,1557,4530,2657, # 640
|
89 |
-
1921, 395,2754,2685,3819,4216,1836, 125, 916,3209,2626,4531,5052,5053,3820,5054, # 656
|
90 |
-
5055,5056,4532,3142,3691,1133,2555,1757,3462,1510,2318,1409,3569,5057,2146, 438, # 672
|
91 |
-
2601,2910,2384,3354,1068, 958,3043, 461, 311,2869,2686,4217,1916,3210,4218,1979, # 688
|
92 |
-
383, 750,2755,2627,4219, 274, 539, 385,1278,1442,5058,1154,1965, 384, 561, 210, # 704
|
93 |
-
98,1295,2556,3570,5059,1711,2420,1482,3463,3987,2911,1257, 129,5060,3821, 642, # 720
|
94 |
-
523,2789,2790,2658,5061, 141,2235,1333, 68, 176, 441, 876, 907,4220, 603,2602, # 736
|
95 |
-
710, 171,3464, 404, 549, 18,3143,2398,1410,3692,1666,5062,3571,4533,2912,4534, # 752
|
96 |
-
5063,2991, 368,5064, 146, 366, 99, 871,3693,1543, 748, 807,1586,1185, 22,2263, # 768
|
97 |
-
379,3822,3211,5065,3212, 505,1942,2628,1992,1382,2319,5066, 380,2362, 218, 702, # 784
|
98 |
-
1818,1248,3465,3044,3572,3355,3282,5067,2992,3694, 930,3283,3823,5068, 59,5069, # 800
|
99 |
-
585, 601,4221, 497,3466,1112,1314,4535,1802,5070,1223,1472,2177,5071, 749,1837, # 816
|
100 |
-
690,1900,3824,1773,3988,1476, 429,1043,1791,2236,2117, 917,4222, 447,1086,1629, # 832
|
101 |
-
5072, 556,5073,5074,2021,1654, 844,1090, 105, 550, 966,1758,2828,1008,1783, 686, # 848
|
102 |
-
1095,5075,2287, 793,1602,5076,3573,2603,4536,4223,2948,2302,4537,3825, 980,2503, # 864
|
103 |
-
544, 353, 527,4538, 908,2687,2913,5077, 381,2629,1943,1348,5078,1341,1252, 560, # 880
|
104 |
-
3095,5079,3467,2870,5080,2054, 973, 886,2081, 143,4539,5081,5082, 157,3989, 496, # 896
|
105 |
-
4224, 57, 840, 540,2039,4540,4541,3468,2118,1445, 970,2264,1748,1966,2082,4225, # 912
|
106 |
-
3144,1234,1776,3284,2829,3695, 773,1206,2130,1066,2040,1326,3990,1738,1725,4226, # 928
|
107 |
-
279,3145, 51,1544,2604, 423,1578,2131,2067, 173,4542,1880,5083,5084,1583, 264, # 944
|
108 |
-
610,3696,4543,2444, 280, 154,5085,5086,5087,1739, 338,1282,3096, 693,2871,1411, # 960
|
109 |
-
1074,3826,2445,5088,4544,5089,5090,1240, 952,2399,5091,2914,1538,2688, 685,1483, # 976
|
110 |
-
4227,2475,1436, 953,4228,2055,4545, 671,2400, 79,4229,2446,3285, 608, 567,2689, # 992
|
111 |
-
3469,4230,4231,1691, 393,1261,1792,2401,5092,4546,5093,5094,5095,5096,1383,1672, # 1008
|
112 |
-
3827,3213,1464, 522,1119, 661,1150, 216, 675,4547,3991,1432,3574, 609,4548,2690, # 1024
|
113 |
-
2402,5097,5098,5099,4232,3045, 0,5100,2476, 315, 231,2447, 301,3356,4549,2385, # 1040
|
114 |
-
5101, 233,4233,3697,1819,4550,4551,5102, 96,1777,1315,2083,5103, 257,5104,1810, # 1056
|
115 |
-
3698,2718,1139,1820,4234,2022,1124,2164,2791,1778,2659,5105,3097, 363,1655,3214, # 1072
|
116 |
-
5106,2993,5107,5108,5109,3992,1567,3993, 718, 103,3215, 849,1443, 341,3357,2949, # 1088
|
117 |
-
1484,5110,1712, 127, 67, 339,4235,2403, 679,1412, 821,5111,5112, 834, 738, 351, # 1104
|
118 |
-
2994,2147, 846, 235,1497,1881, 418,1993,3828,2719, 186,1100,2148,2756,3575,1545, # 1120
|
119 |
-
1355,2950,2872,1377, 583,3994,4236,2581,2995,5113,1298,3699,1078,2557,3700,2363, # 1136
|
120 |
-
78,3829,3830, 267,1289,2100,2002,1594,4237, 348, 369,1274,2197,2178,1838,4552, # 1152
|
121 |
-
1821,2830,3701,2757,2288,2003,4553,2951,2758, 144,3358, 882,4554,3995,2759,3470, # 1168
|
122 |
-
4555,2915,5114,4238,1726, 320,5115,3996,3046, 788,2996,5116,2831,1774,1327,2873, # 1184
|
123 |
-
3997,2832,5117,1306,4556,2004,1700,3831,3576,2364,2660, 787,2023, 506, 824,3702, # 1200
|
124 |
-
534, 323,4557,1044,3359,2024,1901, 946,3471,5118,1779,1500,1678,5119,1882,4558, # 1216
|
125 |
-
165, 243,4559,3703,2528, 123, 683,4239, 764,4560, 36,3998,1793, 589,2916, 816, # 1232
|
126 |
-
626,1667,3047,2237,1639,1555,1622,3832,3999,5120,4000,2874,1370,1228,1933, 891, # 1248
|
127 |
-
2084,2917, 304,4240,5121, 292,2997,2720,3577, 691,2101,4241,1115,4561, 118, 662, # 1264
|
128 |
-
5122, 611,1156, 854,2386,1316,2875, 2, 386, 515,2918,5123,5124,3286, 868,2238, # 1280
|
129 |
-
1486, 855,2661, 785,2216,3048,5125,1040,3216,3578,5126,3146, 448,5127,1525,5128, # 1296
|
130 |
-
2165,4562,5129,3833,5130,4242,2833,3579,3147, 503, 818,4001,3148,1568, 814, 676, # 1312
|
131 |
-
1444, 306,1749,5131,3834,1416,1030, 197,1428, 805,2834,1501,4563,5132,5133,5134, # 1328
|
132 |
-
1994,5135,4564,5136,5137,2198, 13,2792,3704,2998,3149,1229,1917,5138,3835,2132, # 1344
|
133 |
-
5139,4243,4565,2404,3580,5140,2217,1511,1727,1120,5141,5142, 646,3836,2448, 307, # 1360
|
134 |
-
5143,5144,1595,3217,5145,5146,5147,3705,1113,1356,4002,1465,2529,2530,5148, 519, # 1376
|
135 |
-
5149, 128,2133, 92,2289,1980,5150,4003,1512, 342,3150,2199,5151,2793,2218,1981, # 1392
|
136 |
-
3360,4244, 290,1656,1317, 789, 827,2365,5152,3837,4566, 562, 581,4004,5153, 401, # 1408
|
137 |
-
4567,2252, 94,4568,5154,1399,2794,5155,1463,2025,4569,3218,1944,5156, 828,1105, # 1424
|
138 |
-
4245,1262,1394,5157,4246, 605,4570,5158,1784,2876,5159,2835, 819,2102, 578,2200, # 1440
|
139 |
-
2952,5160,1502, 436,3287,4247,3288,2836,4005,2919,3472,3473,5161,2721,2320,5162, # 1456
|
140 |
-
5163,2337,2068, 23,4571, 193, 826,3838,2103, 699,1630,4248,3098, 390,1794,1064, # 1472
|
141 |
-
3581,5164,1579,3099,3100,1400,5165,4249,1839,1640,2877,5166,4572,4573, 137,4250, # 1488
|
142 |
-
598,3101,1967, 780, 104, 974,2953,5167, 278, 899, 253, 402, 572, 504, 493,1339, # 1504
|
143 |
-
5168,4006,1275,4574,2582,2558,5169,3706,3049,3102,2253, 565,1334,2722, 863, 41, # 1520
|
144 |
-
5170,5171,4575,5172,1657,2338, 19, 463,2760,4251, 606,5173,2999,3289,1087,2085, # 1536
|
145 |
-
1323,2662,3000,5174,1631,1623,1750,4252,2691,5175,2878, 791,2723,2663,2339, 232, # 1552
|
146 |
-
2421,5176,3001,1498,5177,2664,2630, 755,1366,3707,3290,3151,2026,1609, 119,1918, # 1568
|
147 |
-
3474, 862,1026,4253,5178,4007,3839,4576,4008,4577,2265,1952,2477,5179,1125, 817, # 1584
|
148 |
-
4254,4255,4009,1513,1766,2041,1487,4256,3050,3291,2837,3840,3152,5180,5181,1507, # 1600
|
149 |
-
5182,2692, 733, 40,1632,1106,2879, 345,4257, 841,2531, 230,4578,3002,1847,3292, # 1616
|
150 |
-
3475,5183,1263, 986,3476,5184, 735, 879, 254,1137, 857, 622,1300,1180,1388,1562, # 1632
|
151 |
-
4010,4011,2954, 967,2761,2665,1349, 592,2134,1692,3361,3003,1995,4258,1679,4012, # 1648
|
152 |
-
1902,2188,5185, 739,3708,2724,1296,1290,5186,4259,2201,2202,1922,1563,2605,2559, # 1664
|
153 |
-
1871,2762,3004,5187, 435,5188, 343,1108, 596, 17,1751,4579,2239,3477,3709,5189, # 1680
|
154 |
-
4580, 294,3582,2955,1693, 477, 979, 281,2042,3583, 643,2043,3710,2631,2795,2266, # 1696
|
155 |
-
1031,2340,2135,2303,3584,4581, 367,1249,2560,5190,3585,5191,4582,1283,3362,2005, # 1712
|
156 |
-
240,1762,3363,4583,4584, 836,1069,3153, 474,5192,2149,2532, 268,3586,5193,3219, # 1728
|
157 |
-
1521,1284,5194,1658,1546,4260,5195,3587,3588,5196,4261,3364,2693,1685,4262, 961, # 1744
|
158 |
-
1673,2632, 190,2006,2203,3841,4585,4586,5197, 570,2504,3711,1490,5198,4587,2633, # 1760
|
159 |
-
3293,1957,4588, 584,1514, 396,1045,1945,5199,4589,1968,2449,5200,5201,4590,4013, # 1776
|
160 |
-
619,5202,3154,3294, 215,2007,2796,2561,3220,4591,3221,4592, 763,4263,3842,4593, # 1792
|
161 |
-
5203,5204,1958,1767,2956,3365,3712,1174, 452,1477,4594,3366,3155,5205,2838,1253, # 1808
|
162 |
-
2387,2189,1091,2290,4264, 492,5206, 638,1169,1825,2136,1752,4014, 648, 926,1021, # 1824
|
163 |
-
1324,4595, 520,4596, 997, 847,1007, 892,4597,3843,2267,1872,3713,2405,1785,4598, # 1840
|
164 |
-
1953,2957,3103,3222,1728,4265,2044,3714,4599,2008,1701,3156,1551, 30,2268,4266, # 1856
|
165 |
-
5207,2027,4600,3589,5208, 501,5209,4267, 594,3478,2166,1822,3590,3479,3591,3223, # 1872
|
166 |
-
829,2839,4268,5210,1680,3157,1225,4269,5211,3295,4601,4270,3158,2341,5212,4602, # 1888
|
167 |
-
4271,5213,4015,4016,5214,1848,2388,2606,3367,5215,4603, 374,4017, 652,4272,4273, # 1904
|
168 |
-
375,1140, 798,5216,5217,5218,2366,4604,2269, 546,1659, 138,3051,2450,4605,5219, # 1920
|
169 |
-
2254, 612,1849, 910, 796,3844,1740,1371, 825,3845,3846,5220,2920,2562,5221, 692, # 1936
|
170 |
-
444,3052,2634, 801,4606,4274,5222,1491, 244,1053,3053,4275,4276, 340,5223,4018, # 1952
|
171 |
-
1041,3005, 293,1168, 87,1357,5224,1539, 959,5225,2240, 721, 694,4277,3847, 219, # 1968
|
172 |
-
1478, 644,1417,3368,2666,1413,1401,1335,1389,4019,5226,5227,3006,2367,3159,1826, # 1984
|
173 |
-
730,1515, 184,2840, 66,4607,5228,1660,2958, 246,3369, 378,1457, 226,3480, 975, # 2000
|
174 |
-
4020,2959,1264,3592, 674, 696,5229, 163,5230,1141,2422,2167, 713,3593,3370,4608, # 2016
|
175 |
-
4021,5231,5232,1186, 15,5233,1079,1070,5234,1522,3224,3594, 276,1050,2725, 758, # 2032
|
176 |
-
1126, 653,2960,3296,5235,2342, 889,3595,4022,3104,3007, 903,1250,4609,4023,3481, # 2048
|
177 |
-
3596,1342,1681,1718, 766,3297, 286, 89,2961,3715,5236,1713,5237,2607,3371,3008, # 2064
|
178 |
-
5238,2962,2219,3225,2880,5239,4610,2505,2533, 181, 387,1075,4024, 731,2190,3372, # 2080
|
179 |
-
5240,3298, 310, 313,3482,2304, 770,4278, 54,3054, 189,4611,3105,3848,4025,5241, # 2096
|
180 |
-
1230,1617,1850, 355,3597,4279,4612,3373, 111,4280,3716,1350,3160,3483,3055,4281, # 2112
|
181 |
-
2150,3299,3598,5242,2797,4026,4027,3009, 722,2009,5243,1071, 247,1207,2343,2478, # 2128
|
182 |
-
1378,4613,2010, 864,1437,1214,4614, 373,3849,1142,2220, 667,4615, 442,2763,2563, # 2144
|
183 |
-
3850,4028,1969,4282,3300,1840, 837, 170,1107, 934,1336,1883,5244,5245,2119,4283, # 2160
|
184 |
-
2841, 743,1569,5246,4616,4284, 582,2389,1418,3484,5247,1803,5248, 357,1395,1729, # 2176
|
185 |
-
3717,3301,2423,1564,2241,5249,3106,3851,1633,4617,1114,2086,4285,1532,5250, 482, # 2192
|
186 |
-
2451,4618,5251,5252,1492, 833,1466,5253,2726,3599,1641,2842,5254,1526,1272,3718, # 2208
|
187 |
-
4286,1686,1795, 416,2564,1903,1954,1804,5255,3852,2798,3853,1159,2321,5256,2881, # 2224
|
188 |
-
4619,1610,1584,3056,2424,2764, 443,3302,1163,3161,5257,5258,4029,5259,4287,2506, # 2240
|
189 |
-
3057,4620,4030,3162,2104,1647,3600,2011,1873,4288,5260,4289, 431,3485,5261, 250, # 2256
|
190 |
-
97, 81,4290,5262,1648,1851,1558, 160, 848,5263, 866, 740,1694,5264,2204,2843, # 2272
|
191 |
-
3226,4291,4621,3719,1687, 950,2479, 426, 469,3227,3720,3721,4031,5265,5266,1188, # 2288
|
192 |
-
424,1996, 861,3601,4292,3854,2205,2694, 168,1235,3602,4293,5267,2087,1674,4622, # 2304
|
193 |
-
3374,3303, 220,2565,1009,5268,3855, 670,3010, 332,1208, 717,5269,5270,3603,2452, # 2320
|
194 |
-
4032,3375,5271, 513,5272,1209,2882,3376,3163,4623,1080,5273,5274,5275,5276,2534, # 2336
|
195 |
-
3722,3604, 815,1587,4033,4034,5277,3605,3486,3856,1254,4624,1328,3058,1390,4035, # 2352
|
196 |
-
1741,4036,3857,4037,5278, 236,3858,2453,3304,5279,5280,3723,3859,1273,3860,4625, # 2368
|
197 |
-
5281, 308,5282,4626, 245,4627,1852,2480,1307,2583, 430, 715,2137,2454,5283, 270, # 2384
|
198 |
-
199,2883,4038,5284,3606,2727,1753, 761,1754, 725,1661,1841,4628,3487,3724,5285, # 2400
|
199 |
-
5286, 587, 14,3305, 227,2608, 326, 480,2270, 943,2765,3607, 291, 650,1884,5287, # 2416
|
200 |
-
1702,1226, 102,1547, 62,3488, 904,4629,3489,1164,4294,5288,5289,1224,1548,2766, # 2432
|
201 |
-
391, 498,1493,5290,1386,1419,5291,2056,1177,4630, 813, 880,1081,2368, 566,1145, # 2448
|
202 |
-
4631,2291,1001,1035,2566,2609,2242, 394,1286,5292,5293,2069,5294, 86,1494,1730, # 2464
|
203 |
-
4039, 491,1588, 745, 897,2963, 843,3377,4040,2767,2884,3306,1768, 998,2221,2070, # 2480
|
204 |
-
397,1827,1195,1970,3725,3011,3378, 284,5295,3861,2507,2138,2120,1904,5296,4041, # 2496
|
205 |
-
2151,4042,4295,1036,3490,1905, 114,2567,4296, 209,1527,5297,5298,2964,2844,2635, # 2512
|
206 |
-
2390,2728,3164, 812,2568,5299,3307,5300,1559, 737,1885,3726,1210, 885, 28,2695, # 2528
|
207 |
-
3608,3862,5301,4297,1004,1780,4632,5302, 346,1982,2222,2696,4633,3863,1742, 797, # 2544
|
208 |
-
1642,4043,1934,1072,1384,2152, 896,4044,3308,3727,3228,2885,3609,5303,2569,1959, # 2560
|
209 |
-
4634,2455,1786,5304,5305,5306,4045,4298,1005,1308,3728,4299,2729,4635,4636,1528, # 2576
|
210 |
-
2610, 161,1178,4300,1983, 987,4637,1101,4301, 631,4046,1157,3229,2425,1343,1241, # 2592
|
211 |
-
1016,2243,2570, 372, 877,2344,2508,1160, 555,1935, 911,4047,5307, 466,1170, 169, # 2608
|
212 |
-
1051,2921,2697,3729,2481,3012,1182,2012,2571,1251,2636,5308, 992,2345,3491,1540, # 2624
|
213 |
-
2730,1201,2071,2406,1997,2482,5309,4638, 528,1923,2191,1503,1874,1570,2369,3379, # 2640
|
214 |
-
3309,5310, 557,1073,5311,1828,3492,2088,2271,3165,3059,3107, 767,3108,2799,4639, # 2656
|
215 |
-
1006,4302,4640,2346,1267,2179,3730,3230, 778,4048,3231,2731,1597,2667,5312,4641, # 2672
|
216 |
-
5313,3493,5314,5315,5316,3310,2698,1433,3311, 131, 95,1504,4049, 723,4303,3166, # 2688
|
217 |
-
1842,3610,2768,2192,4050,2028,2105,3731,5317,3013,4051,1218,5318,3380,3232,4052, # 2704
|
218 |
-
4304,2584, 248,1634,3864, 912,5319,2845,3732,3060,3865, 654, 53,5320,3014,5321, # 2720
|
219 |
-
1688,4642, 777,3494,1032,4053,1425,5322, 191, 820,2121,2846, 971,4643, 931,3233, # 2736
|
220 |
-
135, 664, 783,3866,1998, 772,2922,1936,4054,3867,4644,2923,3234, 282,2732, 640, # 2752
|
221 |
-
1372,3495,1127, 922, 325,3381,5323,5324, 711,2045,5325,5326,4055,2223,2800,1937, # 2768
|
222 |
-
4056,3382,2224,2255,3868,2305,5327,4645,3869,1258,3312,4057,3235,2139,2965,4058, # 2784
|
223 |
-
4059,5328,2225, 258,3236,4646, 101,1227,5329,3313,1755,5330,1391,3314,5331,2924, # 2800
|
224 |
-
2057, 893,5332,5333,5334,1402,4305,2347,5335,5336,3237,3611,5337,5338, 878,1325, # 2816
|
225 |
-
1781,2801,4647, 259,1385,2585, 744,1183,2272,4648,5339,4060,2509,5340, 684,1024, # 2832
|
226 |
-
4306,5341, 472,3612,3496,1165,3315,4061,4062, 322,2153, 881, 455,1695,1152,1340, # 2848
|
227 |
-
660, 554,2154,4649,1058,4650,4307, 830,1065,3383,4063,4651,1924,5342,1703,1919, # 2864
|
228 |
-
5343, 932,2273, 122,5344,4652, 947, 677,5345,3870,2637, 297,1906,1925,2274,4653, # 2880
|
229 |
-
2322,3316,5346,5347,4308,5348,4309, 84,4310, 112, 989,5349, 547,1059,4064, 701, # 2896
|
230 |
-
3613,1019,5350,4311,5351,3497, 942, 639, 457,2306,2456, 993,2966, 407, 851, 494, # 2912
|
231 |
-
4654,3384, 927,5352,1237,5353,2426,3385, 573,4312, 680, 921,2925,1279,1875, 285, # 2928
|
232 |
-
790,1448,1984, 719,2168,5354,5355,4655,4065,4066,1649,5356,1541, 563,5357,1077, # 2944
|
233 |
-
5358,3386,3061,3498, 511,3015,4067,4068,3733,4069,1268,2572,3387,3238,4656,4657, # 2960
|
234 |
-
5359, 535,1048,1276,1189,2926,2029,3167,1438,1373,2847,2967,1134,2013,5360,4313, # 2976
|
235 |
-
1238,2586,3109,1259,5361, 700,5362,2968,3168,3734,4314,5363,4315,1146,1876,1907, # 2992
|
236 |
-
4658,2611,4070, 781,2427, 132,1589, 203, 147, 273,2802,2407, 898,1787,2155,4071, # 3008
|
237 |
-
4072,5364,3871,2803,5365,5366,4659,4660,5367,3239,5368,1635,3872, 965,5369,1805, # 3024
|
238 |
-
2699,1516,3614,1121,1082,1329,3317,4073,1449,3873, 65,1128,2848,2927,2769,1590, # 3040
|
239 |
-
3874,5370,5371, 12,2668, 45, 976,2587,3169,4661, 517,2535,1013,1037,3240,5372, # 3056
|
240 |
-
3875,2849,5373,3876,5374,3499,5375,2612, 614,1999,2323,3877,3110,2733,2638,5376, # 3072
|
241 |
-
2588,4316, 599,1269,5377,1811,3735,5378,2700,3111, 759,1060, 489,1806,3388,3318, # 3088
|
242 |
-
1358,5379,5380,2391,1387,1215,2639,2256, 490,5381,5382,4317,1759,2392,2348,5383, # 3104
|
243 |
-
4662,3878,1908,4074,2640,1807,3241,4663,3500,3319,2770,2349, 874,5384,5385,3501, # 3120
|
244 |
-
3736,1859, 91,2928,3737,3062,3879,4664,5386,3170,4075,2669,5387,3502,1202,1403, # 3136
|
245 |
-
3880,2969,2536,1517,2510,4665,3503,2511,5388,4666,5389,2701,1886,1495,1731,4076, # 3152
|
246 |
-
2370,4667,5390,2030,5391,5392,4077,2702,1216, 237,2589,4318,2324,4078,3881,4668, # 3168
|
247 |
-
4669,2703,3615,3504, 445,4670,5393,5394,5395,5396,2771, 61,4079,3738,1823,4080, # 3184
|
248 |
-
5397, 687,2046, 935, 925, 405,2670, 703,1096,1860,2734,4671,4081,1877,1367,2704, # 3200
|
249 |
-
3389, 918,2106,1782,2483, 334,3320,1611,1093,4672, 564,3171,3505,3739,3390, 945, # 3216
|
250 |
-
2641,2058,4673,5398,1926, 872,4319,5399,3506,2705,3112, 349,4320,3740,4082,4674, # 3232
|
251 |
-
3882,4321,3741,2156,4083,4675,4676,4322,4677,2408,2047, 782,4084, 400, 251,4323, # 3248
|
252 |
-
1624,5400,5401, 277,3742, 299,1265, 476,1191,3883,2122,4324,4325,1109, 205,5402, # 3264
|
253 |
-
2590,1000,2157,3616,1861,5403,5404,5405,4678,5406,4679,2573, 107,2484,2158,4085, # 3280
|
254 |
-
3507,3172,5407,1533, 541,1301, 158, 753,4326,2886,3617,5408,1696, 370,1088,4327, # 3296
|
255 |
-
4680,3618, 579, 327, 440, 162,2244, 269,1938,1374,3508, 968,3063, 56,1396,3113, # 3312
|
256 |
-
2107,3321,3391,5409,1927,2159,4681,3016,5410,3619,5411,5412,3743,4682,2485,5413, # 3328
|
257 |
-
2804,5414,1650,4683,5415,2613,5416,5417,4086,2671,3392,1149,3393,4087,3884,4088, # 3344
|
258 |
-
5418,1076, 49,5419, 951,3242,3322,3323, 450,2850, 920,5420,1812,2805,2371,4328, # 3360
|
259 |
-
1909,1138,2372,3885,3509,5421,3243,4684,1910,1147,1518,2428,4685,3886,5422,4686, # 3376
|
260 |
-
2393,2614, 260,1796,3244,5423,5424,3887,3324, 708,5425,3620,1704,5426,3621,1351, # 3392
|
261 |
-
1618,3394,3017,1887, 944,4329,3395,4330,3064,3396,4331,5427,3744, 422, 413,1714, # 3408
|
262 |
-
3325, 500,2059,2350,4332,2486,5428,1344,1911, 954,5429,1668,5430,5431,4089,2409, # 3424
|
263 |
-
4333,3622,3888,4334,5432,2307,1318,2512,3114, 133,3115,2887,4687, 629, 31,2851, # 3440
|
264 |
-
2706,3889,4688, 850, 949,4689,4090,2970,1732,2089,4335,1496,1853,5433,4091, 620, # 3456
|
265 |
-
3245, 981,1242,3745,3397,1619,3746,1643,3326,2140,2457,1971,1719,3510,2169,5434, # 3472
|
266 |
-
3246,5435,5436,3398,1829,5437,1277,4690,1565,2048,5438,1636,3623,3116,5439, 869, # 3488
|
267 |
-
2852, 655,3890,3891,3117,4092,3018,3892,1310,3624,4691,5440,5441,5442,1733, 558, # 3504
|
268 |
-
4692,3747, 335,1549,3065,1756,4336,3748,1946,3511,1830,1291,1192, 470,2735,2108, # 3520
|
269 |
-
2806, 913,1054,4093,5443,1027,5444,3066,4094,4693, 982,2672,3399,3173,3512,3247, # 3536
|
270 |
-
3248,1947,2807,5445, 571,4694,5446,1831,5447,3625,2591,1523,2429,5448,2090, 984, # 3552
|
271 |
-
4695,3749,1960,5449,3750, 852, 923,2808,3513,3751, 969,1519, 999,2049,2325,1705, # 3568
|
272 |
-
5450,3118, 615,1662, 151, 597,4095,2410,2326,1049, 275,4696,3752,4337, 568,3753, # 3584
|
273 |
-
3626,2487,4338,3754,5451,2430,2275, 409,3249,5452,1566,2888,3514,1002, 769,2853, # 3600
|
274 |
-
194,2091,3174,3755,2226,3327,4339, 628,1505,5453,5454,1763,2180,3019,4096, 521, # 3616
|
275 |
-
1161,2592,1788,2206,2411,4697,4097,1625,4340,4341, 412, 42,3119, 464,5455,2642, # 3632
|
276 |
-
4698,3400,1760,1571,2889,3515,2537,1219,2207,3893,2643,2141,2373,4699,4700,3328, # 3648
|
277 |
-
1651,3401,3627,5456,5457,3628,2488,3516,5458,3756,5459,5460,2276,2092, 460,5461, # 3664
|
278 |
-
4701,5462,3020, 962, 588,3629, 289,3250,2644,1116, 52,5463,3067,1797,5464,5465, # 3680
|
279 |
-
5466,1467,5467,1598,1143,3757,4342,1985,1734,1067,4702,1280,3402, 465,4703,1572, # 3696
|
280 |
-
510,5468,1928,2245,1813,1644,3630,5469,4704,3758,5470,5471,2673,1573,1534,5472, # 3712
|
281 |
-
5473, 536,1808,1761,3517,3894,3175,2645,5474,5475,5476,4705,3518,2929,1912,2809, # 3728
|
282 |
-
5477,3329,1122, 377,3251,5478, 360,5479,5480,4343,1529, 551,5481,2060,3759,1769, # 3744
|
283 |
-
2431,5482,2930,4344,3330,3120,2327,2109,2031,4706,1404, 136,1468,1479, 672,1171, # 3760
|
284 |
-
3252,2308, 271,3176,5483,2772,5484,2050, 678,2736, 865,1948,4707,5485,2014,4098, # 3776
|
285 |
-
2971,5486,2737,2227,1397,3068,3760,4708,4709,1735,2931,3403,3631,5487,3895, 509, # 3792
|
286 |
-
2854,2458,2890,3896,5488,5489,3177,3178,4710,4345,2538,4711,2309,1166,1010, 552, # 3808
|
287 |
-
681,1888,5490,5491,2972,2973,4099,1287,1596,1862,3179, 358, 453, 736, 175, 478, # 3824
|
288 |
-
1117, 905,1167,1097,5492,1854,1530,5493,1706,5494,2181,3519,2292,3761,3520,3632, # 3840
|
289 |
-
4346,2093,4347,5495,3404,1193,2489,4348,1458,2193,2208,1863,1889,1421,3331,2932, # 3856
|
290 |
-
3069,2182,3521, 595,2123,5496,4100,5497,5498,4349,1707,2646, 223,3762,1359, 751, # 3872
|
291 |
-
3121, 183,3522,5499,2810,3021, 419,2374, 633, 704,3897,2394, 241,5500,5501,5502, # 3888
|
292 |
-
838,3022,3763,2277,2773,2459,3898,1939,2051,4101,1309,3122,2246,1181,5503,1136, # 3904
|
293 |
-
2209,3899,2375,1446,4350,2310,4712,5504,5505,4351,1055,2615, 484,3764,5506,4102, # 3920
|
294 |
-
625,4352,2278,3405,1499,4353,4103,5507,4104,4354,3253,2279,2280,3523,5508,5509, # 3936
|
295 |
-
2774, 808,2616,3765,3406,4105,4355,3123,2539, 526,3407,3900,4356, 955,5510,1620, # 3952
|
296 |
-
4357,2647,2432,5511,1429,3766,1669,1832, 994, 928,5512,3633,1260,5513,5514,5515, # 3968
|
297 |
-
1949,2293, 741,2933,1626,4358,2738,2460, 867,1184, 362,3408,1392,5516,5517,4106, # 3984
|
298 |
-
4359,1770,1736,3254,2934,4713,4714,1929,2707,1459,1158,5518,3070,3409,2891,1292, # 4000
|
299 |
-
1930,2513,2855,3767,1986,1187,2072,2015,2617,4360,5519,2574,2514,2170,3768,2490, # 4016
|
300 |
-
3332,5520,3769,4715,5521,5522, 666,1003,3023,1022,3634,4361,5523,4716,1814,2257, # 4032
|
301 |
-
574,3901,1603, 295,1535, 705,3902,4362, 283, 858, 417,5524,5525,3255,4717,4718, # 4048
|
302 |
-
3071,1220,1890,1046,2281,2461,4107,1393,1599, 689,2575, 388,4363,5526,2491, 802, # 4064
|
303 |
-
5527,2811,3903,2061,1405,2258,5528,4719,3904,2110,1052,1345,3256,1585,5529, 809, # 4080
|
304 |
-
5530,5531,5532, 575,2739,3524, 956,1552,1469,1144,2328,5533,2329,1560,2462,3635, # 4096
|
305 |
-
3257,4108, 616,2210,4364,3180,2183,2294,5534,1833,5535,3525,4720,5536,1319,3770, # 4112
|
306 |
-
3771,1211,3636,1023,3258,1293,2812,5537,5538,5539,3905, 607,2311,3906, 762,2892, # 4128
|
307 |
-
1439,4365,1360,4721,1485,3072,5540,4722,1038,4366,1450,2062,2648,4367,1379,4723, # 4144
|
308 |
-
2593,5541,5542,4368,1352,1414,2330,2935,1172,5543,5544,3907,3908,4724,1798,1451, # 4160
|
309 |
-
5545,5546,5547,5548,2936,4109,4110,2492,2351, 411,4111,4112,3637,3333,3124,4725, # 4176
|
310 |
-
1561,2674,1452,4113,1375,5549,5550, 47,2974, 316,5551,1406,1591,2937,3181,5552, # 4192
|
311 |
-
1025,2142,3125,3182, 354,2740, 884,2228,4369,2412, 508,3772, 726,3638, 996,2433, # 4208
|
312 |
-
3639, 729,5553, 392,2194,1453,4114,4726,3773,5554,5555,2463,3640,2618,1675,2813, # 4224
|
313 |
-
919,2352,2975,2353,1270,4727,4115, 73,5556,5557, 647,5558,3259,2856,2259,1550, # 4240
|
314 |
-
1346,3024,5559,1332, 883,3526,5560,5561,5562,5563,3334,2775,5564,1212, 831,1347, # 4256
|
315 |
-
4370,4728,2331,3909,1864,3073, 720,3910,4729,4730,3911,5565,4371,5566,5567,4731, # 4272
|
316 |
-
5568,5569,1799,4732,3774,2619,4733,3641,1645,2376,4734,5570,2938, 669,2211,2675, # 4288
|
317 |
-
2434,5571,2893,5572,5573,1028,3260,5574,4372,2413,5575,2260,1353,5576,5577,4735, # 4304
|
318 |
-
3183, 518,5578,4116,5579,4373,1961,5580,2143,4374,5581,5582,3025,2354,2355,3912, # 4320
|
319 |
-
516,1834,1454,4117,2708,4375,4736,2229,2620,1972,1129,3642,5583,2776,5584,2976, # 4336
|
320 |
-
1422, 577,1470,3026,1524,3410,5585,5586, 432,4376,3074,3527,5587,2594,1455,2515, # 4352
|
321 |
-
2230,1973,1175,5588,1020,2741,4118,3528,4737,5589,2742,5590,1743,1361,3075,3529, # 4368
|
322 |
-
2649,4119,4377,4738,2295, 895, 924,4378,2171, 331,2247,3076, 166,1627,3077,1098, # 4384
|
323 |
-
5591,1232,2894,2231,3411,4739, 657, 403,1196,2377, 542,3775,3412,1600,4379,3530, # 4400
|
324 |
-
5592,4740,2777,3261, 576, 530,1362,4741,4742,2540,2676,3776,4120,5593, 842,3913, # 4416
|
325 |
-
5594,2814,2032,1014,4121, 213,2709,3413, 665, 621,4380,5595,3777,2939,2435,5596, # 4432
|
326 |
-
2436,3335,3643,3414,4743,4381,2541,4382,4744,3644,1682,4383,3531,1380,5597, 724, # 4448
|
327 |
-
2282, 600,1670,5598,1337,1233,4745,3126,2248,5599,1621,4746,5600, 651,4384,5601, # 4464
|
328 |
-
1612,4385,2621,5602,2857,5603,2743,2312,3078,5604, 716,2464,3079, 174,1255,2710, # 4480
|
329 |
-
4122,3645, 548,1320,1398, 728,4123,1574,5605,1891,1197,3080,4124,5606,3081,3082, # 4496
|
330 |
-
3778,3646,3779, 747,5607, 635,4386,4747,5608,5609,5610,4387,5611,5612,4748,5613, # 4512
|
331 |
-
3415,4749,2437, 451,5614,3780,2542,2073,4388,2744,4389,4125,5615,1764,4750,5616, # 4528
|
332 |
-
4390, 350,4751,2283,2395,2493,5617,4391,4126,2249,1434,4127, 488,4752, 458,4392, # 4544
|
333 |
-
4128,3781, 771,1330,2396,3914,2576,3184,2160,2414,1553,2677,3185,4393,5618,2494, # 4560
|
334 |
-
2895,2622,1720,2711,4394,3416,4753,5619,2543,4395,5620,3262,4396,2778,5621,2016, # 4576
|
335 |
-
2745,5622,1155,1017,3782,3915,5623,3336,2313, 201,1865,4397,1430,5624,4129,5625, # 4592
|
336 |
-
5626,5627,5628,5629,4398,1604,5630, 414,1866, 371,2595,4754,4755,3532,2017,3127, # 4608
|
337 |
-
4756,1708, 960,4399, 887, 389,2172,1536,1663,1721,5631,2232,4130,2356,2940,1580, # 4624
|
338 |
-
5632,5633,1744,4757,2544,4758,4759,5634,4760,5635,2074,5636,4761,3647,3417,2896, # 4640
|
339 |
-
4400,5637,4401,2650,3418,2815, 673,2712,2465, 709,3533,4131,3648,4402,5638,1148, # 4656
|
340 |
-
502, 634,5639,5640,1204,4762,3649,1575,4763,2623,3783,5641,3784,3128, 948,3263, # 4672
|
341 |
-
121,1745,3916,1110,5642,4403,3083,2516,3027,4132,3785,1151,1771,3917,1488,4133, # 4688
|
342 |
-
1987,5643,2438,3534,5644,5645,2094,5646,4404,3918,1213,1407,2816, 531,2746,2545, # 4704
|
343 |
-
3264,1011,1537,4764,2779,4405,3129,1061,5647,3786,3787,1867,2897,5648,2018, 120, # 4720
|
344 |
-
4406,4407,2063,3650,3265,2314,3919,2678,3419,1955,4765,4134,5649,3535,1047,2713, # 4736
|
345 |
-
1266,5650,1368,4766,2858, 649,3420,3920,2546,2747,1102,2859,2679,5651,5652,2000, # 4752
|
346 |
-
5653,1111,3651,2977,5654,2495,3921,3652,2817,1855,3421,3788,5655,5656,3422,2415, # 4768
|
347 |
-
2898,3337,3266,3653,5657,2577,5658,3654,2818,4135,1460, 856,5659,3655,5660,2899, # 4784
|
348 |
-
2978,5661,2900,3922,5662,4408, 632,2517, 875,3923,1697,3924,2296,5663,5664,4767, # 4800
|
349 |
-
3028,1239, 580,4768,4409,5665, 914, 936,2075,1190,4136,1039,2124,5666,5667,5668, # 4816
|
350 |
-
5669,3423,1473,5670,1354,4410,3925,4769,2173,3084,4137, 915,3338,4411,4412,3339, # 4832
|
351 |
-
1605,1835,5671,2748, 398,3656,4413,3926,4138, 328,1913,2860,4139,3927,1331,4414, # 4848
|
352 |
-
3029, 937,4415,5672,3657,4140,4141,3424,2161,4770,3425, 524, 742, 538,3085,1012, # 4864
|
353 |
-
5673,5674,3928,2466,5675, 658,1103, 225,3929,5676,5677,4771,5678,4772,5679,3267, # 4880
|
354 |
-
1243,5680,4142, 963,2250,4773,5681,2714,3658,3186,5682,5683,2596,2332,5684,4774, # 4896
|
355 |
-
5685,5686,5687,3536, 957,3426,2547,2033,1931,2941,2467, 870,2019,3659,1746,2780, # 4912
|
356 |
-
2781,2439,2468,5688,3930,5689,3789,3130,3790,3537,3427,3791,5690,1179,3086,5691, # 4928
|
357 |
-
3187,2378,4416,3792,2548,3188,3131,2749,4143,5692,3428,1556,2549,2297, 977,2901, # 4944
|
358 |
-
2034,4144,1205,3429,5693,1765,3430,3189,2125,1271, 714,1689,4775,3538,5694,2333, # 4960
|
359 |
-
3931, 533,4417,3660,2184, 617,5695,2469,3340,3539,2315,5696,5697,3190,5698,5699, # 4976
|
360 |
-
3932,1988, 618, 427,2651,3540,3431,5700,5701,1244,1690,5702,2819,4418,4776,5703, # 4992
|
361 |
-
3541,4777,5704,2284,1576, 473,3661,4419,3432, 972,5705,3662,5706,3087,5707,5708, # 5008
|
362 |
-
4778,4779,5709,3793,4145,4146,5710, 153,4780, 356,5711,1892,2902,4420,2144, 408, # 5024
|
363 |
-
803,2357,5712,3933,5713,4421,1646,2578,2518,4781,4782,3934,5714,3935,4422,5715, # 5040
|
364 |
-
2416,3433, 752,5716,5717,1962,3341,2979,5718, 746,3030,2470,4783,4423,3794, 698, # 5056
|
365 |
-
4784,1893,4424,3663,2550,4785,3664,3936,5719,3191,3434,5720,1824,1302,4147,2715, # 5072
|
366 |
-
3937,1974,4425,5721,4426,3192, 823,1303,1288,1236,2861,3542,4148,3435, 774,3938, # 5088
|
367 |
-
5722,1581,4786,1304,2862,3939,4787,5723,2440,2162,1083,3268,4427,4149,4428, 344, # 5104
|
368 |
-
1173, 288,2316, 454,1683,5724,5725,1461,4788,4150,2597,5726,5727,4789, 985, 894, # 5120
|
369 |
-
5728,3436,3193,5729,1914,2942,3795,1989,5730,2111,1975,5731,4151,5732,2579,1194, # 5136
|
370 |
-
425,5733,4790,3194,1245,3796,4429,5734,5735,2863,5736, 636,4791,1856,3940, 760, # 5152
|
371 |
-
1800,5737,4430,2212,1508,4792,4152,1894,1684,2298,5738,5739,4793,4431,4432,2213, # 5168
|
372 |
-
479,5740,5741, 832,5742,4153,2496,5743,2980,2497,3797, 990,3132, 627,1815,2652, # 5184
|
373 |
-
4433,1582,4434,2126,2112,3543,4794,5744, 799,4435,3195,5745,4795,2113,1737,3031, # 5200
|
374 |
-
1018, 543, 754,4436,3342,1676,4796,4797,4154,4798,1489,5746,3544,5747,2624,2903, # 5216
|
375 |
-
4155,5748,5749,2981,5750,5751,5752,5753,3196,4799,4800,2185,1722,5754,3269,3270, # 5232
|
376 |
-
1843,3665,1715, 481, 365,1976,1857,5755,5756,1963,2498,4801,5757,2127,3666,3271, # 5248
|
377 |
-
433,1895,2064,2076,5758, 602,2750,5759,5760,5761,5762,5763,3032,1628,3437,5764, # 5264
|
378 |
-
3197,4802,4156,2904,4803,2519,5765,2551,2782,5766,5767,5768,3343,4804,2905,5769, # 5280
|
379 |
-
4805,5770,2864,4806,4807,1221,2982,4157,2520,5771,5772,5773,1868,1990,5774,5775, # 5296
|
380 |
-
5776,1896,5777,5778,4808,1897,4158, 318,5779,2095,4159,4437,5780,5781, 485,5782, # 5312
|
381 |
-
938,3941, 553,2680, 116,5783,3942,3667,5784,3545,2681,2783,3438,3344,2820,5785, # 5328
|
382 |
-
3668,2943,4160,1747,2944,2983,5786,5787, 207,5788,4809,5789,4810,2521,5790,3033, # 5344
|
383 |
-
890,3669,3943,5791,1878,3798,3439,5792,2186,2358,3440,1652,5793,5794,5795, 941, # 5360
|
384 |
-
2299, 208,3546,4161,2020, 330,4438,3944,2906,2499,3799,4439,4811,5796,5797,5798, # 5376
|
385 |
-
)
|
386 |
-
# fmt: on
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated.h
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
// Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
-
#pragma once
|
3 |
-
#include <torch/types.h>
|
4 |
-
|
5 |
-
namespace detectron2 {
|
6 |
-
|
7 |
-
at::Tensor ROIAlignRotated_forward_cpu(
|
8 |
-
const at::Tensor& input,
|
9 |
-
const at::Tensor& rois,
|
10 |
-
const float spatial_scale,
|
11 |
-
const int pooled_height,
|
12 |
-
const int pooled_width,
|
13 |
-
const int sampling_ratio);
|
14 |
-
|
15 |
-
at::Tensor ROIAlignRotated_backward_cpu(
|
16 |
-
const at::Tensor& grad,
|
17 |
-
const at::Tensor& rois,
|
18 |
-
const float spatial_scale,
|
19 |
-
const int pooled_height,
|
20 |
-
const int pooled_width,
|
21 |
-
const int batch_size,
|
22 |
-
const int channels,
|
23 |
-
const int height,
|
24 |
-
const int width,
|
25 |
-
const int sampling_ratio);
|
26 |
-
|
27 |
-
#if defined(WITH_CUDA) || defined(WITH_HIP)
|
28 |
-
at::Tensor ROIAlignRotated_forward_cuda(
|
29 |
-
const at::Tensor& input,
|
30 |
-
const at::Tensor& rois,
|
31 |
-
const float spatial_scale,
|
32 |
-
const int pooled_height,
|
33 |
-
const int pooled_width,
|
34 |
-
const int sampling_ratio);
|
35 |
-
|
36 |
-
at::Tensor ROIAlignRotated_backward_cuda(
|
37 |
-
const at::Tensor& grad,
|
38 |
-
const at::Tensor& rois,
|
39 |
-
const float spatial_scale,
|
40 |
-
const int pooled_height,
|
41 |
-
const int pooled_width,
|
42 |
-
const int batch_size,
|
43 |
-
const int channels,
|
44 |
-
const int height,
|
45 |
-
const int width,
|
46 |
-
const int sampling_ratio);
|
47 |
-
#endif
|
48 |
-
|
49 |
-
// Interface for Python
|
50 |
-
inline at::Tensor ROIAlignRotated_forward(
|
51 |
-
const at::Tensor& input,
|
52 |
-
const at::Tensor& rois,
|
53 |
-
const double spatial_scale,
|
54 |
-
const int64_t pooled_height,
|
55 |
-
const int64_t pooled_width,
|
56 |
-
const int64_t sampling_ratio) {
|
57 |
-
if (input.is_cuda()) {
|
58 |
-
#if defined(WITH_CUDA) || defined(WITH_HIP)
|
59 |
-
return ROIAlignRotated_forward_cuda(
|
60 |
-
input,
|
61 |
-
rois,
|
62 |
-
spatial_scale,
|
63 |
-
pooled_height,
|
64 |
-
pooled_width,
|
65 |
-
sampling_ratio);
|
66 |
-
#else
|
67 |
-
AT_ERROR("Detectron2 is not compiled with GPU support!");
|
68 |
-
#endif
|
69 |
-
}
|
70 |
-
return ROIAlignRotated_forward_cpu(
|
71 |
-
input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio);
|
72 |
-
}
|
73 |
-
|
74 |
-
inline at::Tensor ROIAlignRotated_backward(
|
75 |
-
const at::Tensor& grad,
|
76 |
-
const at::Tensor& rois,
|
77 |
-
const double spatial_scale,
|
78 |
-
const int64_t pooled_height,
|
79 |
-
const int64_t pooled_width,
|
80 |
-
const int64_t batch_size,
|
81 |
-
const int64_t channels,
|
82 |
-
const int64_t height,
|
83 |
-
const int64_t width,
|
84 |
-
const int64_t sampling_ratio) {
|
85 |
-
if (grad.is_cuda()) {
|
86 |
-
#if defined(WITH_CUDA) || defined(WITH_HIP)
|
87 |
-
return ROIAlignRotated_backward_cuda(
|
88 |
-
grad,
|
89 |
-
rois,
|
90 |
-
spatial_scale,
|
91 |
-
pooled_height,
|
92 |
-
pooled_width,
|
93 |
-
batch_size,
|
94 |
-
channels,
|
95 |
-
height,
|
96 |
-
width,
|
97 |
-
sampling_ratio);
|
98 |
-
#else
|
99 |
-
AT_ERROR("Detectron2 is not compiled with GPU support!");
|
100 |
-
#endif
|
101 |
-
}
|
102 |
-
return ROIAlignRotated_backward_cpu(
|
103 |
-
grad,
|
104 |
-
rois,
|
105 |
-
spatial_scale,
|
106 |
-
pooled_height,
|
107 |
-
pooled_width,
|
108 |
-
batch_size,
|
109 |
-
channels,
|
110 |
-
height,
|
111 |
-
width,
|
112 |
-
sampling_ratio);
|
113 |
-
}
|
114 |
-
|
115 |
-
} // namespace detectron2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/data/test_rotation_transform.py
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
-
import numpy as np
|
3 |
-
import unittest
|
4 |
-
|
5 |
-
from detectron2.data.transforms.transform import RotationTransform
|
6 |
-
|
7 |
-
|
8 |
-
class TestRotationTransform(unittest.TestCase):
|
9 |
-
def assertEqualsArrays(self, a1, a2):
|
10 |
-
self.assertTrue(np.allclose(a1, a2))
|
11 |
-
|
12 |
-
def randomData(self, h=5, w=5):
|
13 |
-
image = np.random.rand(h, w)
|
14 |
-
coords = np.array([[i, j] for j in range(h + 1) for i in range(w + 1)], dtype=float)
|
15 |
-
return image, coords, h, w
|
16 |
-
|
17 |
-
def test180(self):
|
18 |
-
image, coords, h, w = self.randomData(6, 6)
|
19 |
-
rot = RotationTransform(h, w, 180, expand=False, center=None)
|
20 |
-
self.assertEqualsArrays(rot.apply_image(image), image[::-1, ::-1])
|
21 |
-
rotated_coords = [[w - c[0], h - c[1]] for c in coords]
|
22 |
-
self.assertEqualsArrays(rot.apply_coords(coords), rotated_coords)
|
23 |
-
|
24 |
-
def test45_coords(self):
|
25 |
-
_, coords, h, w = self.randomData(4, 6)
|
26 |
-
rot = RotationTransform(h, w, 45, expand=False, center=None)
|
27 |
-
rotated_coords = [
|
28 |
-
[(x + y - (h + w) / 2) / np.sqrt(2) + w / 2, h / 2 + (y + (w - h) / 2 - x) / np.sqrt(2)]
|
29 |
-
for (x, y) in coords
|
30 |
-
]
|
31 |
-
self.assertEqualsArrays(rot.apply_coords(coords), rotated_coords)
|
32 |
-
|
33 |
-
def test90(self):
|
34 |
-
image, coords, h, w = self.randomData()
|
35 |
-
rot = RotationTransform(h, w, 90, expand=False, center=None)
|
36 |
-
self.assertEqualsArrays(rot.apply_image(image), image.T[::-1])
|
37 |
-
rotated_coords = [[c[1], w - c[0]] for c in coords]
|
38 |
-
self.assertEqualsArrays(rot.apply_coords(coords), rotated_coords)
|
39 |
-
|
40 |
-
def test90_expand(self): # non-square image
|
41 |
-
image, coords, h, w = self.randomData(h=5, w=8)
|
42 |
-
rot = RotationTransform(h, w, 90, expand=True, center=None)
|
43 |
-
self.assertEqualsArrays(rot.apply_image(image), image.T[::-1])
|
44 |
-
rotated_coords = [[c[1], w - c[0]] for c in coords]
|
45 |
-
self.assertEqualsArrays(rot.apply_coords(coords), rotated_coords)
|
46 |
-
|
47 |
-
def test_center_expand(self):
|
48 |
-
# center has no effect if expand=True because it only affects shifting
|
49 |
-
image, coords, h, w = self.randomData(h=5, w=8)
|
50 |
-
angle = np.random.randint(360)
|
51 |
-
rot1 = RotationTransform(h, w, angle, expand=True, center=None)
|
52 |
-
rot2 = RotationTransform(h, w, angle, expand=True, center=(0, 0))
|
53 |
-
rot3 = RotationTransform(h, w, angle, expand=True, center=(h, w))
|
54 |
-
rot4 = RotationTransform(h, w, angle, expand=True, center=(2, 5))
|
55 |
-
for r1 in [rot1, rot2, rot3, rot4]:
|
56 |
-
for r2 in [rot1, rot2, rot3, rot4]:
|
57 |
-
self.assertEqualsArrays(r1.apply_image(image), r2.apply_image(image))
|
58 |
-
self.assertEqualsArrays(r1.apply_coords(coords), r2.apply_coords(coords))
|
59 |
-
|
60 |
-
def test_inverse_transform(self):
|
61 |
-
image, coords, h, w = self.randomData(h=5, w=8)
|
62 |
-
rot = RotationTransform(h, w, 90, expand=True, center=None)
|
63 |
-
rot_image = rot.apply_image(image)
|
64 |
-
self.assertEqualsArrays(rot.inverse().apply_image(rot_image), image)
|
65 |
-
rot = RotationTransform(h, w, 65, expand=True, center=None)
|
66 |
-
rotated_coords = rot.apply_coords(coords)
|
67 |
-
self.assertEqualsArrays(rot.inverse().apply_coords(rotated_coords), coords)
|
68 |
-
|
69 |
-
|
70 |
-
if __name__ == "__main__":
|
71 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Bambicita/rvc-models/infer_pack/modules.py
DELETED
@@ -1,522 +0,0 @@
|
|
1 |
-
import copy
|
2 |
-
import math
|
3 |
-
import numpy as np
|
4 |
-
import scipy
|
5 |
-
import torch
|
6 |
-
from torch import nn
|
7 |
-
from torch.nn import functional as F
|
8 |
-
|
9 |
-
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
10 |
-
from torch.nn.utils import weight_norm, remove_weight_norm
|
11 |
-
|
12 |
-
from infer_pack import commons
|
13 |
-
from infer_pack.commons import init_weights, get_padding
|
14 |
-
from infer_pack.transforms import piecewise_rational_quadratic_transform
|
15 |
-
|
16 |
-
|
17 |
-
LRELU_SLOPE = 0.1
|
18 |
-
|
19 |
-
|
20 |
-
class LayerNorm(nn.Module):
|
21 |
-
def __init__(self, channels, eps=1e-5):
|
22 |
-
super().__init__()
|
23 |
-
self.channels = channels
|
24 |
-
self.eps = eps
|
25 |
-
|
26 |
-
self.gamma = nn.Parameter(torch.ones(channels))
|
27 |
-
self.beta = nn.Parameter(torch.zeros(channels))
|
28 |
-
|
29 |
-
def forward(self, x):
|
30 |
-
x = x.transpose(1, -1)
|
31 |
-
x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps)
|
32 |
-
return x.transpose(1, -1)
|
33 |
-
|
34 |
-
|
35 |
-
class ConvReluNorm(nn.Module):
|
36 |
-
def __init__(
|
37 |
-
self,
|
38 |
-
in_channels,
|
39 |
-
hidden_channels,
|
40 |
-
out_channels,
|
41 |
-
kernel_size,
|
42 |
-
n_layers,
|
43 |
-
p_dropout,
|
44 |
-
):
|
45 |
-
super().__init__()
|
46 |
-
self.in_channels = in_channels
|
47 |
-
self.hidden_channels = hidden_channels
|
48 |
-
self.out_channels = out_channels
|
49 |
-
self.kernel_size = kernel_size
|
50 |
-
self.n_layers = n_layers
|
51 |
-
self.p_dropout = p_dropout
|
52 |
-
assert n_layers > 1, "Number of layers should be larger than 0."
|
53 |
-
|
54 |
-
self.conv_layers = nn.ModuleList()
|
55 |
-
self.norm_layers = nn.ModuleList()
|
56 |
-
self.conv_layers.append(
|
57 |
-
nn.Conv1d(
|
58 |
-
in_channels, hidden_channels, kernel_size, padding=kernel_size // 2
|
59 |
-
)
|
60 |
-
)
|
61 |
-
self.norm_layers.append(LayerNorm(hidden_channels))
|
62 |
-
self.relu_drop = nn.Sequential(nn.ReLU(), nn.Dropout(p_dropout))
|
63 |
-
for _ in range(n_layers - 1):
|
64 |
-
self.conv_layers.append(
|
65 |
-
nn.Conv1d(
|
66 |
-
hidden_channels,
|
67 |
-
hidden_channels,
|
68 |
-
kernel_size,
|
69 |
-
padding=kernel_size // 2,
|
70 |
-
)
|
71 |
-
)
|
72 |
-
self.norm_layers.append(LayerNorm(hidden_channels))
|
73 |
-
self.proj = nn.Conv1d(hidden_channels, out_channels, 1)
|
74 |
-
self.proj.weight.data.zero_()
|
75 |
-
self.proj.bias.data.zero_()
|
76 |
-
|
77 |
-
def forward(self, x, x_mask):
|
78 |
-
x_org = x
|
79 |
-
for i in range(self.n_layers):
|
80 |
-
x = self.conv_layers[i](x * x_mask)
|
81 |
-
x = self.norm_layers[i](x)
|
82 |
-
x = self.relu_drop(x)
|
83 |
-
x = x_org + self.proj(x)
|
84 |
-
return x * x_mask
|
85 |
-
|
86 |
-
|
87 |
-
class DDSConv(nn.Module):
|
88 |
-
"""
|
89 |
-
Dialted and Depth-Separable Convolution
|
90 |
-
"""
|
91 |
-
|
92 |
-
def __init__(self, channels, kernel_size, n_layers, p_dropout=0.0):
|
93 |
-
super().__init__()
|
94 |
-
self.channels = channels
|
95 |
-
self.kernel_size = kernel_size
|
96 |
-
self.n_layers = n_layers
|
97 |
-
self.p_dropout = p_dropout
|
98 |
-
|
99 |
-
self.drop = nn.Dropout(p_dropout)
|
100 |
-
self.convs_sep = nn.ModuleList()
|
101 |
-
self.convs_1x1 = nn.ModuleList()
|
102 |
-
self.norms_1 = nn.ModuleList()
|
103 |
-
self.norms_2 = nn.ModuleList()
|
104 |
-
for i in range(n_layers):
|
105 |
-
dilation = kernel_size**i
|
106 |
-
padding = (kernel_size * dilation - dilation) // 2
|
107 |
-
self.convs_sep.append(
|
108 |
-
nn.Conv1d(
|
109 |
-
channels,
|
110 |
-
channels,
|
111 |
-
kernel_size,
|
112 |
-
groups=channels,
|
113 |
-
dilation=dilation,
|
114 |
-
padding=padding,
|
115 |
-
)
|
116 |
-
)
|
117 |
-
self.convs_1x1.append(nn.Conv1d(channels, channels, 1))
|
118 |
-
self.norms_1.append(LayerNorm(channels))
|
119 |
-
self.norms_2.append(LayerNorm(channels))
|
120 |
-
|
121 |
-
def forward(self, x, x_mask, g=None):
|
122 |
-
if g is not None:
|
123 |
-
x = x + g
|
124 |
-
for i in range(self.n_layers):
|
125 |
-
y = self.convs_sep[i](x * x_mask)
|
126 |
-
y = self.norms_1[i](y)
|
127 |
-
y = F.gelu(y)
|
128 |
-
y = self.convs_1x1[i](y)
|
129 |
-
y = self.norms_2[i](y)
|
130 |
-
y = F.gelu(y)
|
131 |
-
y = self.drop(y)
|
132 |
-
x = x + y
|
133 |
-
return x * x_mask
|
134 |
-
|
135 |
-
|
136 |
-
class WN(torch.nn.Module):
|
137 |
-
def __init__(
|
138 |
-
self,
|
139 |
-
hidden_channels,
|
140 |
-
kernel_size,
|
141 |
-
dilation_rate,
|
142 |
-
n_layers,
|
143 |
-
gin_channels=0,
|
144 |
-
p_dropout=0,
|
145 |
-
):
|
146 |
-
super(WN, self).__init__()
|
147 |
-
assert kernel_size % 2 == 1
|
148 |
-
self.hidden_channels = hidden_channels
|
149 |
-
self.kernel_size = (kernel_size,)
|
150 |
-
self.dilation_rate = dilation_rate
|
151 |
-
self.n_layers = n_layers
|
152 |
-
self.gin_channels = gin_channels
|
153 |
-
self.p_dropout = p_dropout
|
154 |
-
|
155 |
-
self.in_layers = torch.nn.ModuleList()
|
156 |
-
self.res_skip_layers = torch.nn.ModuleList()
|
157 |
-
self.drop = nn.Dropout(p_dropout)
|
158 |
-
|
159 |
-
if gin_channels != 0:
|
160 |
-
cond_layer = torch.nn.Conv1d(
|
161 |
-
gin_channels, 2 * hidden_channels * n_layers, 1
|
162 |
-
)
|
163 |
-
self.cond_layer = torch.nn.utils.weight_norm(cond_layer, name="weight")
|
164 |
-
|
165 |
-
for i in range(n_layers):
|
166 |
-
dilation = dilation_rate**i
|
167 |
-
padding = int((kernel_size * dilation - dilation) / 2)
|
168 |
-
in_layer = torch.nn.Conv1d(
|
169 |
-
hidden_channels,
|
170 |
-
2 * hidden_channels,
|
171 |
-
kernel_size,
|
172 |
-
dilation=dilation,
|
173 |
-
padding=padding,
|
174 |
-
)
|
175 |
-
in_layer = torch.nn.utils.weight_norm(in_layer, name="weight")
|
176 |
-
self.in_layers.append(in_layer)
|
177 |
-
|
178 |
-
# last one is not necessary
|
179 |
-
if i < n_layers - 1:
|
180 |
-
res_skip_channels = 2 * hidden_channels
|
181 |
-
else:
|
182 |
-
res_skip_channels = hidden_channels
|
183 |
-
|
184 |
-
res_skip_layer = torch.nn.Conv1d(hidden_channels, res_skip_channels, 1)
|
185 |
-
res_skip_layer = torch.nn.utils.weight_norm(res_skip_layer, name="weight")
|
186 |
-
self.res_skip_layers.append(res_skip_layer)
|
187 |
-
|
188 |
-
def forward(self, x, x_mask, g=None, **kwargs):
|
189 |
-
output = torch.zeros_like(x)
|
190 |
-
n_channels_tensor = torch.IntTensor([self.hidden_channels])
|
191 |
-
|
192 |
-
if g is not None:
|
193 |
-
g = self.cond_layer(g)
|
194 |
-
|
195 |
-
for i in range(self.n_layers):
|
196 |
-
x_in = self.in_layers[i](x)
|
197 |
-
if g is not None:
|
198 |
-
cond_offset = i * 2 * self.hidden_channels
|
199 |
-
g_l = g[:, cond_offset : cond_offset + 2 * self.hidden_channels, :]
|
200 |
-
else:
|
201 |
-
g_l = torch.zeros_like(x_in)
|
202 |
-
|
203 |
-
acts = commons.fused_add_tanh_sigmoid_multiply(x_in, g_l, n_channels_tensor)
|
204 |
-
acts = self.drop(acts)
|
205 |
-
|
206 |
-
res_skip_acts = self.res_skip_layers[i](acts)
|
207 |
-
if i < self.n_layers - 1:
|
208 |
-
res_acts = res_skip_acts[:, : self.hidden_channels, :]
|
209 |
-
x = (x + res_acts) * x_mask
|
210 |
-
output = output + res_skip_acts[:, self.hidden_channels :, :]
|
211 |
-
else:
|
212 |
-
output = output + res_skip_acts
|
213 |
-
return output * x_mask
|
214 |
-
|
215 |
-
def remove_weight_norm(self):
|
216 |
-
if self.gin_channels != 0:
|
217 |
-
torch.nn.utils.remove_weight_norm(self.cond_layer)
|
218 |
-
for l in self.in_layers:
|
219 |
-
torch.nn.utils.remove_weight_norm(l)
|
220 |
-
for l in self.res_skip_layers:
|
221 |
-
torch.nn.utils.remove_weight_norm(l)
|
222 |
-
|
223 |
-
|
224 |
-
class ResBlock1(torch.nn.Module):
|
225 |
-
def __init__(self, channels, kernel_size=3, dilation=(1, 3, 5)):
|
226 |
-
super(ResBlock1, self).__init__()
|
227 |
-
self.convs1 = nn.ModuleList(
|
228 |
-
[
|
229 |
-
weight_norm(
|
230 |
-
Conv1d(
|
231 |
-
channels,
|
232 |
-
channels,
|
233 |
-
kernel_size,
|
234 |
-
1,
|
235 |
-
dilation=dilation[0],
|
236 |
-
padding=get_padding(kernel_size, dilation[0]),
|
237 |
-
)
|
238 |
-
),
|
239 |
-
weight_norm(
|
240 |
-
Conv1d(
|
241 |
-
channels,
|
242 |
-
channels,
|
243 |
-
kernel_size,
|
244 |
-
1,
|
245 |
-
dilation=dilation[1],
|
246 |
-
padding=get_padding(kernel_size, dilation[1]),
|
247 |
-
)
|
248 |
-
),
|
249 |
-
weight_norm(
|
250 |
-
Conv1d(
|
251 |
-
channels,
|
252 |
-
channels,
|
253 |
-
kernel_size,
|
254 |
-
1,
|
255 |
-
dilation=dilation[2],
|
256 |
-
padding=get_padding(kernel_size, dilation[2]),
|
257 |
-
)
|
258 |
-
),
|
259 |
-
]
|
260 |
-
)
|
261 |
-
self.convs1.apply(init_weights)
|
262 |
-
|
263 |
-
self.convs2 = nn.ModuleList(
|
264 |
-
[
|
265 |
-
weight_norm(
|
266 |
-
Conv1d(
|
267 |
-
channels,
|
268 |
-
channels,
|
269 |
-
kernel_size,
|
270 |
-
1,
|
271 |
-
dilation=1,
|
272 |
-
padding=get_padding(kernel_size, 1),
|
273 |
-
)
|
274 |
-
),
|
275 |
-
weight_norm(
|
276 |
-
Conv1d(
|
277 |
-
channels,
|
278 |
-
channels,
|
279 |
-
kernel_size,
|
280 |
-
1,
|
281 |
-
dilation=1,
|
282 |
-
padding=get_padding(kernel_size, 1),
|
283 |
-
)
|
284 |
-
),
|
285 |
-
weight_norm(
|
286 |
-
Conv1d(
|
287 |
-
channels,
|
288 |
-
channels,
|
289 |
-
kernel_size,
|
290 |
-
1,
|
291 |
-
dilation=1,
|
292 |
-
padding=get_padding(kernel_size, 1),
|
293 |
-
)
|
294 |
-
),
|
295 |
-
]
|
296 |
-
)
|
297 |
-
self.convs2.apply(init_weights)
|
298 |
-
|
299 |
-
def forward(self, x, x_mask=None):
|
300 |
-
for c1, c2 in zip(self.convs1, self.convs2):
|
301 |
-
xt = F.leaky_relu(x, LRELU_SLOPE)
|
302 |
-
if x_mask is not None:
|
303 |
-
xt = xt * x_mask
|
304 |
-
xt = c1(xt)
|
305 |
-
xt = F.leaky_relu(xt, LRELU_SLOPE)
|
306 |
-
if x_mask is not None:
|
307 |
-
xt = xt * x_mask
|
308 |
-
xt = c2(xt)
|
309 |
-
x = xt + x
|
310 |
-
if x_mask is not None:
|
311 |
-
x = x * x_mask
|
312 |
-
return x
|
313 |
-
|
314 |
-
def remove_weight_norm(self):
|
315 |
-
for l in self.convs1:
|
316 |
-
remove_weight_norm(l)
|
317 |
-
for l in self.convs2:
|
318 |
-
remove_weight_norm(l)
|
319 |
-
|
320 |
-
|
321 |
-
class ResBlock2(torch.nn.Module):
|
322 |
-
def __init__(self, channels, kernel_size=3, dilation=(1, 3)):
|
323 |
-
super(ResBlock2, self).__init__()
|
324 |
-
self.convs = nn.ModuleList(
|
325 |
-
[
|
326 |
-
weight_norm(
|
327 |
-
Conv1d(
|
328 |
-
channels,
|
329 |
-
channels,
|
330 |
-
kernel_size,
|
331 |
-
1,
|
332 |
-
dilation=dilation[0],
|
333 |
-
padding=get_padding(kernel_size, dilation[0]),
|
334 |
-
)
|
335 |
-
),
|
336 |
-
weight_norm(
|
337 |
-
Conv1d(
|
338 |
-
channels,
|
339 |
-
channels,
|
340 |
-
kernel_size,
|
341 |
-
1,
|
342 |
-
dilation=dilation[1],
|
343 |
-
padding=get_padding(kernel_size, dilation[1]),
|
344 |
-
)
|
345 |
-
),
|
346 |
-
]
|
347 |
-
)
|
348 |
-
self.convs.apply(init_weights)
|
349 |
-
|
350 |
-
def forward(self, x, x_mask=None):
|
351 |
-
for c in self.convs:
|
352 |
-
xt = F.leaky_relu(x, LRELU_SLOPE)
|
353 |
-
if x_mask is not None:
|
354 |
-
xt = xt * x_mask
|
355 |
-
xt = c(xt)
|
356 |
-
x = xt + x
|
357 |
-
if x_mask is not None:
|
358 |
-
x = x * x_mask
|
359 |
-
return x
|
360 |
-
|
361 |
-
def remove_weight_norm(self):
|
362 |
-
for l in self.convs:
|
363 |
-
remove_weight_norm(l)
|
364 |
-
|
365 |
-
|
366 |
-
class Log(nn.Module):
|
367 |
-
def forward(self, x, x_mask, reverse=False, **kwargs):
|
368 |
-
if not reverse:
|
369 |
-
y = torch.log(torch.clamp_min(x, 1e-5)) * x_mask
|
370 |
-
logdet = torch.sum(-y, [1, 2])
|
371 |
-
return y, logdet
|
372 |
-
else:
|
373 |
-
x = torch.exp(x) * x_mask
|
374 |
-
return x
|
375 |
-
|
376 |
-
|
377 |
-
class Flip(nn.Module):
|
378 |
-
def forward(self, x, *args, reverse=False, **kwargs):
|
379 |
-
x = torch.flip(x, [1])
|
380 |
-
if not reverse:
|
381 |
-
logdet = torch.zeros(x.size(0)).to(dtype=x.dtype, device=x.device)
|
382 |
-
return x, logdet
|
383 |
-
else:
|
384 |
-
return x
|
385 |
-
|
386 |
-
|
387 |
-
class ElementwiseAffine(nn.Module):
|
388 |
-
def __init__(self, channels):
|
389 |
-
super().__init__()
|
390 |
-
self.channels = channels
|
391 |
-
self.m = nn.Parameter(torch.zeros(channels, 1))
|
392 |
-
self.logs = nn.Parameter(torch.zeros(channels, 1))
|
393 |
-
|
394 |
-
def forward(self, x, x_mask, reverse=False, **kwargs):
|
395 |
-
if not reverse:
|
396 |
-
y = self.m + torch.exp(self.logs) * x
|
397 |
-
y = y * x_mask
|
398 |
-
logdet = torch.sum(self.logs * x_mask, [1, 2])
|
399 |
-
return y, logdet
|
400 |
-
else:
|
401 |
-
x = (x - self.m) * torch.exp(-self.logs) * x_mask
|
402 |
-
return x
|
403 |
-
|
404 |
-
|
405 |
-
class ResidualCouplingLayer(nn.Module):
|
406 |
-
def __init__(
|
407 |
-
self,
|
408 |
-
channels,
|
409 |
-
hidden_channels,
|
410 |
-
kernel_size,
|
411 |
-
dilation_rate,
|
412 |
-
n_layers,
|
413 |
-
p_dropout=0,
|
414 |
-
gin_channels=0,
|
415 |
-
mean_only=False,
|
416 |
-
):
|
417 |
-
assert channels % 2 == 0, "channels should be divisible by 2"
|
418 |
-
super().__init__()
|
419 |
-
self.channels = channels
|
420 |
-
self.hidden_channels = hidden_channels
|
421 |
-
self.kernel_size = kernel_size
|
422 |
-
self.dilation_rate = dilation_rate
|
423 |
-
self.n_layers = n_layers
|
424 |
-
self.half_channels = channels // 2
|
425 |
-
self.mean_only = mean_only
|
426 |
-
|
427 |
-
self.pre = nn.Conv1d(self.half_channels, hidden_channels, 1)
|
428 |
-
self.enc = WN(
|
429 |
-
hidden_channels,
|
430 |
-
kernel_size,
|
431 |
-
dilation_rate,
|
432 |
-
n_layers,
|
433 |
-
p_dropout=p_dropout,
|
434 |
-
gin_channels=gin_channels,
|
435 |
-
)
|
436 |
-
self.post = nn.Conv1d(hidden_channels, self.half_channels * (2 - mean_only), 1)
|
437 |
-
self.post.weight.data.zero_()
|
438 |
-
self.post.bias.data.zero_()
|
439 |
-
|
440 |
-
def forward(self, x, x_mask, g=None, reverse=False):
|
441 |
-
x0, x1 = torch.split(x, [self.half_channels] * 2, 1)
|
442 |
-
h = self.pre(x0) * x_mask
|
443 |
-
h = self.enc(h, x_mask, g=g)
|
444 |
-
stats = self.post(h) * x_mask
|
445 |
-
if not self.mean_only:
|
446 |
-
m, logs = torch.split(stats, [self.half_channels] * 2, 1)
|
447 |
-
else:
|
448 |
-
m = stats
|
449 |
-
logs = torch.zeros_like(m)
|
450 |
-
|
451 |
-
if not reverse:
|
452 |
-
x1 = m + x1 * torch.exp(logs) * x_mask
|
453 |
-
x = torch.cat([x0, x1], 1)
|
454 |
-
logdet = torch.sum(logs, [1, 2])
|
455 |
-
return x, logdet
|
456 |
-
else:
|
457 |
-
x1 = (x1 - m) * torch.exp(-logs) * x_mask
|
458 |
-
x = torch.cat([x0, x1], 1)
|
459 |
-
return x
|
460 |
-
|
461 |
-
def remove_weight_norm(self):
|
462 |
-
self.enc.remove_weight_norm()
|
463 |
-
|
464 |
-
|
465 |
-
class ConvFlow(nn.Module):
|
466 |
-
def __init__(
|
467 |
-
self,
|
468 |
-
in_channels,
|
469 |
-
filter_channels,
|
470 |
-
kernel_size,
|
471 |
-
n_layers,
|
472 |
-
num_bins=10,
|
473 |
-
tail_bound=5.0,
|
474 |
-
):
|
475 |
-
super().__init__()
|
476 |
-
self.in_channels = in_channels
|
477 |
-
self.filter_channels = filter_channels
|
478 |
-
self.kernel_size = kernel_size
|
479 |
-
self.n_layers = n_layers
|
480 |
-
self.num_bins = num_bins
|
481 |
-
self.tail_bound = tail_bound
|
482 |
-
self.half_channels = in_channels // 2
|
483 |
-
|
484 |
-
self.pre = nn.Conv1d(self.half_channels, filter_channels, 1)
|
485 |
-
self.convs = DDSConv(filter_channels, kernel_size, n_layers, p_dropout=0.0)
|
486 |
-
self.proj = nn.Conv1d(
|
487 |
-
filter_channels, self.half_channels * (num_bins * 3 - 1), 1
|
488 |
-
)
|
489 |
-
self.proj.weight.data.zero_()
|
490 |
-
self.proj.bias.data.zero_()
|
491 |
-
|
492 |
-
def forward(self, x, x_mask, g=None, reverse=False):
|
493 |
-
x0, x1 = torch.split(x, [self.half_channels] * 2, 1)
|
494 |
-
h = self.pre(x0)
|
495 |
-
h = self.convs(h, x_mask, g=g)
|
496 |
-
h = self.proj(h) * x_mask
|
497 |
-
|
498 |
-
b, c, t = x0.shape
|
499 |
-
h = h.reshape(b, c, -1, t).permute(0, 1, 3, 2) # [b, cx?, t] -> [b, c, t, ?]
|
500 |
-
|
501 |
-
unnormalized_widths = h[..., : self.num_bins] / math.sqrt(self.filter_channels)
|
502 |
-
unnormalized_heights = h[..., self.num_bins : 2 * self.num_bins] / math.sqrt(
|
503 |
-
self.filter_channels
|
504 |
-
)
|
505 |
-
unnormalized_derivatives = h[..., 2 * self.num_bins :]
|
506 |
-
|
507 |
-
x1, logabsdet = piecewise_rational_quadratic_transform(
|
508 |
-
x1,
|
509 |
-
unnormalized_widths,
|
510 |
-
unnormalized_heights,
|
511 |
-
unnormalized_derivatives,
|
512 |
-
inverse=reverse,
|
513 |
-
tails="linear",
|
514 |
-
tail_bound=self.tail_bound,
|
515 |
-
)
|
516 |
-
|
517 |
-
x = torch.cat([x0, x1], 1) * x_mask
|
518 |
-
logdet = torch.sum(logabsdet * x_mask, [1, 2])
|
519 |
-
if not reverse:
|
520 |
-
return x, logdet
|
521 |
-
else:
|
522 |
-
return x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Benson/text-generation/Examples/Descargar Ftbol Real 2010 Para Java.md
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Descargar Real Football 2010 para Java: Una guía para los aficionados al fútbol</h1>
|
3 |
-
<p>Si eres fanático del fútbol y tienes un dispositivo con Java, quizás te interese descargar Real Football 2010, uno de los mejores juegos de fútbol para móviles. En este artículo, te mostraremos cómo descargar y jugar a este juego, así como lo que lo hace tan divertido y realista. </p>
|
4 |
-
<h2>Introducción</h2>
|
5 |
-
<p>El fútbol es uno de los deportes más populares del mundo, y millones de personas lo disfrutan viendo y jugando. Sin embargo, no todos tienen la oportunidad de jugar al fútbol en la vida real, o ver a sus equipos y jugadores favoritos en la televisión. Es por eso que los juegos de fútbol son tan populares, especialmente en dispositivos móviles, ya que le permiten experimentar la emoción y la emoción del fútbol en cualquier momento y en cualquier lugar. </p>
|
6 |
-
<h2>descargar fútbol real 2010 para java</h2><br /><p><b><b>Download Zip</b> ✯✯✯ <a href="https://bltlly.com/2v6LA3">https://bltlly.com/2v6LA3</a></b></p><br /><br />
|
7 |
-
<h3>¿Qué es el fútbol real 2010? </h3>
|
8 |
-
<p>Real Football 2010 es un juego de simulación de fútbol desarrollado por Gameloft, un desarrollador líder y editor de juegos móviles. Fue lanzado en 2009 para varias plataformas, incluyendo Java ME, Android, iOS, Windows Mobile y Nintendo DS. Es la séptima entrega de la serie Real Football, que comenzó en 2004. </p>
|
9 |
-
<h3>¿Por qué descargar Real Football 2010 para Java? </h3>
|
10 |
-
<p>Real Football 2010 es uno de los mejores juegos de fútbol para dispositivos Java, ya que ofrece una experiencia de juego realista e inmersiva. Puedes elegir entre más de 200 equipos y 8 ligas, incluyendo la Liga Premier Inglesa, La Liga, Serie A, Bundesliga y más. También puedes jugar como tus jugadores favoritos, como Lionel Messi, Cristiano Ronaldo, Wayne Rooney, Kaka, etc. Incluso puedes crear tu propio jugador y equipo, y personalizarlos con varias opciones. </p>
|
11 |
-
<h2>Cómo descargar Real Football 2010 para Java</h2>
|
12 |
-
<p>Si quieres descargar Real Football 2010 para tu dispositivo Java, debes seguir estos sencillos pasos:</p>
|
13 |
-
<h3>Paso 1: Encuentra una fuente confiable</h3>
|
14 |
-
|
15 |
-
<h3>Paso 2: Elija su dispositivo y el tamaño de la pantalla</h3>
|
16 |
-
<p>Lo siguiente que tienes que hacer es elegir el dispositivo y el tamaño de la pantalla. Los diferentes dispositivos tienen diferentes tamaños de pantalla y resoluciones, por lo que necesitas encontrar la versión del juego que coincida con tu dispositivo. Por ejemplo, si tienes un teléfono Nokia con un tamaño de pantalla de 240x320, necesitas descargar el juego con esa resolución. Puede consultar las especificaciones de su dispositivo en línea o en el manual. </p>
|
17 |
-
<h3>Paso 3: Descargar e instalar el juego</h3>
|
18 |
-
<p>Lo último que tienes que hacer es descargar e instalar el juego en tu dispositivo. Puedes descargar el juego directamente desde el navegador de tu dispositivo o transferirlo desde tu computadora usando un cable USB o Bluetooth. Una vez que hayas descargado el archivo del juego (normalmente un archivo .jar), debes abrirlo y seguir las instrucciones para instalarlo. Es posible que necesites permitir que el juego acceda a la memoria o red de tu dispositivo. </p>
|
19 |
-
<h2>Cómo jugar Real Football 2010 en Java</h2>
|
20 |
-
<p>Una vez que haya instalado el juego en su dispositivo, usted está listo para jugar Real Football 2010 y disfrutar de sus increíbles características. Aquí hay algunos consejos sobre cómo jugar el juego y qué esperar de él:</p>
|
21 |
-
<h3>Modos de juego</h3>
|
22 |
-
<p>Real Football 2010 ofrece varios modos de juego que se adaptan a diferentes preferencias y niveles de habilidad. Puede elegir entre los siguientes modos:</p>
|
23 |
-
<p></p>
|
24 |
-
<h4>Entrar en el modo de leyenda</h4>
|
25 |
-
<p>Este es el modo más desafiante y gratificante, donde puedes crear tu propio jugador y guiarlo a través de su carrera. Puedes personalizar la apariencia, habilidades, posición y nacionalidad de tu jugador. También puede elegir a qué club unirse, y tratar de impresionar al entrenador y los aficionados. Tendrás que enfrentarte a varios desafíos, como marcar goles, hacer asistencias, ganar trofeos, etc. También tendrás que lidiar con lesiones, transferencias, contratos y presión de los medios. Este modo es una gran manera de sumergirse en la vida de una estrella de fútbol. </p>
|
26 |
-
<h4>Desafía a amigos o al mundo en la Liga RF</h4>
|
27 |
-
|
28 |
-
<h4>Transfiera su equipo personalizado de Real Football Manager</h4>
|
29 |
-
<p>Esta es una característica única que le permite transferir su equipo de Real Football Manager, otro juego de Gameloft, a Real Football 2010. Si has jugado a Real Football Manager, puedes importar tu equipo y jugar con él en Real Football 2010. También puedes exportar tu equipo de Real Football 2010 a Real Football Manager, y seguir administrándolo allí. Esta característica es una gran manera de disfrutar de ambos juegos y crear tu equipo de ensueño. </p>
|
30 |
-
<h3>Características del juego</h3>
|
31 |
-
<p>Real Football 2010 tiene muchas características que lo hacen realista y divertido de jugar. Aquí están algunas de ellas:</p>
|
32 |
-
<h4>Gráficos y animaciones realistas</h4>
|
33 |
-
<p>El juego tiene impresionantes gráficos y animaciones que dan vida al juego. Los jugadores se ven como sus contrapartes reales, y tienen movimientos y expresiones realistas. Los estadios son detallados y animados, con multitudes y pancartas. Los efectos del clima y las sombras se suman a la atmósfera del juego. </p>
|
34 |
-
<h4>Ángulos y comentarios dinámicos de la cámara</h4>
|
35 |
-
<p>El juego tiene diferentes ángulos de cámara que te permiten ver la acción desde diferentes perspectivas. Puede cambiar entre ellos durante el juego, o dejar que el juego elija el mejor ángulo para usted. El juego también tiene un comentario que sigue el juego y añade emoción y emoción. El comentario está disponible en varios idiomas, como inglés, francés, español, alemán, italiano, etc.</p>
|
36 |
-
<h4>Controles y ajustes personalizables</h4>
|
37 |
-
<p>El juego tiene controles y ajustes personalizables que te permiten jugar el juego de la manera que quieras. Puede elegir entre diferentes esquemas de control, como botones virtuales o gestos de pantalla táctil. También puede ajustar el nivel de dificultad, la duración del partido, los efectos de sonido, etc.</p>
|
38 |
-
<h2>Conclusión</h2>
|
39 |
-
|
40 |
-
<h2>Preguntas frecuentes</h2>
|
41 |
-
<p>Aquí hay algunas preguntas frecuentes sobre Real Football 2010 para Java:</p>
|
42 |
-
<ul>
|
43 |
-
<li><b>Q: ¿Cuánto espacio ocupa Real Football 2010 en mi dispositivo? </b></li>
|
44 |
-
<li>A: El tamaño del archivo del juego depende de su dispositivo y el tamaño de la pantalla, pero generalmente es alrededor de 1 MB.</li>
|
45 |
-
<li><b>Q: ¿Puedo jugar Real Football 2010 sin conexión? </b></li>
|
46 |
-
<li>A: Sí, puede jugar la mayoría de los modos de juego sin conexión, a excepción del modo RF League que requiere una conexión a Internet. </li>
|
47 |
-
<li><b>Q: ¿Puedo jugar Real Football 2010 con otros jugadores? </b></li>
|
48 |
-
<li>A: Sí, puedes jugar con otros jugadores en línea en el modo Liga de RF, o localmente a través de Bluetooth en el modo Versus. </li>
|
49 |
-
<li><b>Q: ¿Puedo actualizar Real Football 2010 con nuevos equipos y jugadores? </b></li>
|
50 |
-
<li>A: Sí, puedes actualizar el juego con nuevos equipos y jugadores descargando parches del sitio web de Gameloft o de otras fuentes. </li>
|
51 |
-
<li><b>Q: ¿Puedo jugar Real Football 2010 en otras plataformas? </b></li>
|
52 |
-
<li>A: Sí, puedes jugar Real Football 2010 en otras plataformas, como Android, iOS, Windows Mobile y Nintendo DS. Sin embargo, el juego podría tener algunas diferencias en términos de gráficos, características y jugabilidad. </li>
|
53 |
-
</ul>
|
54 |
-
<p>Espero que este artículo te haya ayudado a descargar y jugar Real Football 2010 para Java. Si tiene alguna pregunta o comentario, por favor deje un comentario a continuación. Gracias por leer y divertirse! </p> 64aa2da5cf<br />
|
55 |
-
<br />
|
56 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Benson/text-generation/Examples/Descargar Gacha Vida Vieja Versin Apk.md
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1> Cómo descargar Gacha Life Old Versión Apk</h1>
|
3 |
-
<p>Gacha Life es un popular juego que te permite crear y personalizar tus propios personajes de anime e interactuar con ellos en varios escenarios. Puedes vestir a tus personajes, entrar en el modo estudio, jugar minijuegos, chatear con otros jugadores y explorar diferentes áreas en el modo vida. Gacha Life tiene millones de fans en todo el mundo que disfrutan expresando su creatividad e imaginación a través de este juego. </p>
|
4 |
-
<p>Sin embargo, no todos están satisfechos con la última versión de Gacha Life. Algunos jugadores prefieren descargar Gacha Life versión antigua apk, que es una versión anterior del juego que se puede instalar en dispositivos Android utilizando un archivo apk. ¿Por qué hacen eso? ¿Cuáles son los beneficios y desventajas de descargar Gacha Life versión antigua apk? ¿Cómo se puede descargar Gacha Life versión antigua apk de forma segura y fácil? En este artículo, vamos a responder a estas preguntas y más. </p>
|
5 |
-
<h2>descargar gacha vida vieja versión apk</h2><br /><p><b><b>Download Zip</b> › <a href="https://bltlly.com/2v6Leb">https://bltlly.com/2v6Leb</a></b></p><br /><br />
|
6 |
-
<h2>¿Cuáles son las características de Gacha Life versión antigua apk? </h2>
|
7 |
-
<p>Gacha Life versión antigua apk es una versión del juego que fue lanzado en enero de 2020. Tiene algunas características que son diferentes de la versión actual de Gacha Life, como:</p>
|
8 |
-
<ul>
|
9 |
-
<li>20 ranuras de caracteres en lugar de 10</li>
|
10 |
-
<li>Más artículos de ropa, peinados, armas, sombreros y accesorios</li>
|
11 |
-
<li>Nuevos elementos, poses y fondos que no estaban disponibles en Gacha Studio y Gachaverse</li>
|
12 |
-
<li>Sin función de chat o modo en línea</li>
|
13 |
-
<li>No hay modo de vida o modo NPC</li>
|
14 |
-
<li>No hay juegos gacha o regalos</li>
|
15 |
-
</ul>
|
16 |
-
<h2>¿Por qué algunas personas prefieren descargar Gacha Life versión antigua apk? </h2>
|
17 |
-
<p>Hay varias razones por las que algunas personas prefieren descargar Gacha Life versión antigua apk sobre la última versión del juego. Algunos de ellos son:</p>
|
18 |
-
<ul>
|
19 |
-
<li>Les gusta el diseño antiguo y el estilo del juego mejor que el nuevo</li>
|
20 |
-
<li>Quieren tener más ranuras de caracteres y opciones de personalización para sus caracteres</li>
|
21 |
-
|
22 |
-
<li>Quieren evitar la función de chat y el modo en línea que pueden exponerlos a contenido inapropiado o acoso cibernético</li>
|
23 |
-
<li>Quieren jugar sin conexión sin necesidad de conexión Wi-Fi o de datos</li>
|
24 |
-
<li>Son nostálgicos por la versión original del juego con el que comenzaron a jugar</li>
|
25 |
-
</ul>
|
26 |
-
<h2>Cómo descargar Gacha Life versión antigua apk? </h2>
|
27 |
-
<p>Si usted es una de esas personas que quieren descargar Gacha Life versión antigua apk, es necesario seguir estos pasos:</p>
|
28 |
-
<ol>
|
29 |
-
<li>Encontrar una fuente confiable para el archivo apk. Usted puede buscar en línea para los sitios web que ofrecen Gacha Life versión antigua apk para su descarga gratuita. Sin embargo, tenga cuidado de no descargar de sitios sospechosos o poco fiables que pueden contener virus o malware. Uno de los sitios que puedes probar es Uptodown, que proporciona archivos apk seguros y verificados para varias aplicaciones y juegos. </li>
|
30 |
-
<li>Habilitar fuentes desconocidas en la configuración del dispositivo. Antes de que pueda instalar un archivo apk en su dispositivo Android, es necesario permitir que el dispositivo para instalar aplicaciones de fuentes desconocidas. Para hacer esto, vaya a la configuración del dispositivo, luego la seguridad y luego habilite fuentes desconocidas. Esto le permitirá instalar aplicaciones que están en la aplicación, como el acceso a su almacenamiento, cámara, micrófono, etc.</li>
|
31 |
-
<li>Disfruta jugando Gacha Life versión antigua. Una vez finalizada la instalación, puede iniciar la aplicación y comenzar a jugar la versión antigua de Gacha Life en su dispositivo. Puedes crear y personalizar tus personajes, entrar en el modo estudio, jugar minijuegos y divertirte con tu propio mundo de anime. </li>
|
32 |
-
</ol>
|
33 |
-
<h2>Beneficios de descargar Gacha Life versión antigua apk</h2>
|
34 |
-
<p>Descargar Gacha Life versión antigua apk tiene algunos beneficios que usted no puede obtener de la última versión del juego. Algunos de estos beneficios son:</p>
|
35 |
-
<ul>
|
36 |
-
|
37 |
-
<li>Más ranuras de caracteres y opciones de personalización. La versión antigua de Gacha Life tiene 20 ranuras de caracteres en lugar de 10, lo que significa que puede crear más caracteres y guardarlos para su uso posterior. También tiene más artículos de ropa, peinados, armas, sombreros y accesorios para elegir, así como nuevos artículos, poses y fondos que no estaban disponibles en Gacha Studio y Gachaverse. Puedes dar rienda suelta a tu creatividad y hacer que tus personajes se vean únicos e increíbles. </li>
|
38 |
-
<li>Mejor rendimiento y compatibilidad con dispositivos antiguos. La versión antigua de Gacha Life es menos exigente en los recursos de su dispositivo y se ejecuta más rápido y más suave que la última versión. También funciona bien con dispositivos antiguos que pueden no ser compatibles con las nuevas características o gráficos del juego. Puedes jugar el juego sin experimentar retrasos, fallos o fallos. </li>
|
39 |
-
</ul>
|
40 |
-
<h2>Desventajas de descargar Gacha Life versión antigua apk</h2>
|
41 |
-
<p>Sin embargo, descargar Gacha Vida versión antigua apk también tiene algunos inconvenientes que usted debe ser consciente de antes de decidir hacerlo. Algunos de estos inconvenientes son:</p>
|
42 |
-
<ul>
|
43 |
-
<li>No hay actualizaciones y correcciones de errores del desarrollador. La versión antigua de Gacha Life ya no es compatible con el desarrollador, lo que significa que no recibirá ninguna actualización o corrección de errores para el juego. Esto puede afectar la calidad y funcionalidad del juego, así como su disfrute y satisfacción. </li>
|
44 |
-
<li>Posibles riesgos de seguridad e infecciones de malware. Descargar un archivo apk de una fuente desconocida puede ser arriesgado, ya que puede contener virus o malware que pueden dañar su dispositivo o robar sus datos. Siempre debe escanear el archivo apk antes de instalarlo, y utilizar un antivirus de buena reputación o aplicación de seguridad para proteger su dispositivo. </li>
|
45 |
-
<li>Faltan nuevas características y contenido de la última versión. La última versión de Gacha Life tiene algunas nuevas características y contenido que no encontrarás en la versión anterior, como:</li>
|
46 |
-
<ul>
|
47 |
-
|
48 |
-
<li>Un modo de vida y un modo NPC que te permiten explorar diferentes áreas e interactuar con varios caracteres</li>
|
49 |
-
<li>Juegos y regalos gacha que te permiten ganar gemas y objetos jugando minijuegos o viendo anuncios</li>
|
50 |
-
<li>Nuevos artículos de ropa, peinados, armas, sombreros, accesorios, poses, fondos, etc.</li>
|
51 |
-
</ul>
|
52 |
-
</ul>
|
53 |
-
<h2>Conclusión</h2>
|
54 |
-
<p>Gacha Life es un juego divertido y creativo que te permite crear y personalizar tus propios personajes de anime e interactuar con ellos en varios escenarios. Sin embargo, algunos jugadores prefieren descargar Gacha Vida versión antigua apk sobre la última versión del juego por varias razones. Descargar Gacha Life versión antigua apk tiene algunos beneficios y desventajas que usted debe considerar antes de hacerlo. </p>
|
55 |
-
<p>Si desea descargar Gacha Life versión antigua apk, es necesario encontrar una fuente confiable para el archivo apk, habilitar fuentes desconocidas en la configuración de su dispositivo, descargar e instalar el archivo apk, y disfrutar jugando Gacha Life versión antigua en su dispositivo. Sin embargo, también debe tener cuidado con los posibles riesgos de seguridad y las infecciones de malware que pueden venir con la descarga de un archivo apk de una fuente desconocida. También debe escanear el archivo apk antes de instalarlo, y utilizar un antivirus de buena reputación o aplicación de seguridad para proteger su dispositivo. </p>
|
56 |
-
|
57 |
-
<p>En última instancia, la elección es suya. Usted puede descargar Gacha Vida versión antigua apk si lo desea, o puede seguir con la última versión del juego. De cualquier manera, esperamos que te diviertas y disfrutes jugando a Gacha Life. Si tienes alguna pregunta o comentario, no dudes en compartirlo con nosotros a continuación. Nos encantaría saber de ti. </p>
|
58 |
-
<p></p>
|
59 |
-
<h2>Preguntas frecuentes</h2>
|
60 |
-
<p>Aquí hay algunas preguntas frecuentes sobre la descarga de Gacha Life versión antigua apk:</p>
|
61 |
-
<h3>¿Es legal descargar Gacha Life versión antigua apk? </h3>
|
62 |
-
<p>Depende de la fuente del archivo apk y los términos y condiciones del desarrollador. En general, la descarga de un archivo apk de una fuente de terceros no es ilegal, pero puede violar los derechos de propiedad intelectual del desarrollador o la tienda de aplicaciones. Siempre debe respetar los derechos del desarrollador y la tienda de aplicaciones, y solo descargar un archivo apk de una fuente legítima y autorizada. </p>
|
63 |
-
<h3> ¿Es seguro para descargar Gacha Life versión antigua apk? </h3>
|
64 |
-
<p>No necesariamente. Descargar un archivo apk de una fuente desconocida puede ser arriesgado, ya que puede contener virus o malware que pueden dañar su dispositivo o robar sus datos. Siempre debe escanear el archivo apk antes de instalarlo, y utilizar un antivirus de buena reputación o aplicación de seguridad para proteger su dispositivo. También debe evitar la descarga de un archivo apk de un sitio oscuro o poco fiable que puede contener contenido dañino o ilegal. </p>
|
65 |
-
<h3>¿Cómo puedo actualizar Gacha Life versión antigua apk? </h3>
|
66 |
-
<p>No se puede actualizar Gacha Vida versión antigua apk, ya que ya no es compatible con el desarrollador. Si desea obtener las últimas actualizaciones y correcciones de errores para el juego, es necesario descargar la última versión de Gacha Life de la Google Play Store u otras tiendas de aplicaciones oficiales. Sin embargo, esto sobrescribirá su versión anterior del juego, y perderá algunas de las características y el contenido que estaban disponibles en la versión anterior. </p>
|
67 |
-
<h3>¿Puedo jugar Gacha Vida versión antigua apk en el PC? </h3>
|
68 |
-
|
69 |
-
<h3>¿Puedo transferir mis datos de Gacha Life versión antigua apk a Gacha Life última versión? </h3>
|
70 |
-
<p>No, no puede transferir sus datos de Gacha Life versión antigua apk a Gacha Life última versión. Las dos versiones del juego no son compatibles entre sí, y tienen diferentes características y contenido. Si cambia de Gacha Life versión antigua apk a Gacha Life última versión, perderá todos sus progresos y datos en la versión antigua, tales como sus personajes, artículos, gemas, etc. Usted tendrá que empezar desde cero en la última versión del juego. </p> 64aa2da5cf<br />
|
71 |
-
<br />
|
72 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_vendor/urllib3/connection.py
DELETED
@@ -1,572 +0,0 @@
|
|
1 |
-
from __future__ import absolute_import
|
2 |
-
|
3 |
-
import datetime
|
4 |
-
import logging
|
5 |
-
import os
|
6 |
-
import re
|
7 |
-
import socket
|
8 |
-
import warnings
|
9 |
-
from socket import error as SocketError
|
10 |
-
from socket import timeout as SocketTimeout
|
11 |
-
|
12 |
-
from .packages import six
|
13 |
-
from .packages.six.moves.http_client import HTTPConnection as _HTTPConnection
|
14 |
-
from .packages.six.moves.http_client import HTTPException # noqa: F401
|
15 |
-
from .util.proxy import create_proxy_ssl_context
|
16 |
-
|
17 |
-
try: # Compiled with SSL?
|
18 |
-
import ssl
|
19 |
-
|
20 |
-
BaseSSLError = ssl.SSLError
|
21 |
-
except (ImportError, AttributeError): # Platform-specific: No SSL.
|
22 |
-
ssl = None
|
23 |
-
|
24 |
-
class BaseSSLError(BaseException):
|
25 |
-
pass
|
26 |
-
|
27 |
-
|
28 |
-
try:
|
29 |
-
# Python 3: not a no-op, we're adding this to the namespace so it can be imported.
|
30 |
-
ConnectionError = ConnectionError
|
31 |
-
except NameError:
|
32 |
-
# Python 2
|
33 |
-
class ConnectionError(Exception):
|
34 |
-
pass
|
35 |
-
|
36 |
-
|
37 |
-
try: # Python 3:
|
38 |
-
# Not a no-op, we're adding this to the namespace so it can be imported.
|
39 |
-
BrokenPipeError = BrokenPipeError
|
40 |
-
except NameError: # Python 2:
|
41 |
-
|
42 |
-
class BrokenPipeError(Exception):
|
43 |
-
pass
|
44 |
-
|
45 |
-
|
46 |
-
from ._collections import HTTPHeaderDict # noqa (historical, removed in v2)
|
47 |
-
from ._version import __version__
|
48 |
-
from .exceptions import (
|
49 |
-
ConnectTimeoutError,
|
50 |
-
NewConnectionError,
|
51 |
-
SubjectAltNameWarning,
|
52 |
-
SystemTimeWarning,
|
53 |
-
)
|
54 |
-
from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection
|
55 |
-
from .util.ssl_ import (
|
56 |
-
assert_fingerprint,
|
57 |
-
create_urllib3_context,
|
58 |
-
is_ipaddress,
|
59 |
-
resolve_cert_reqs,
|
60 |
-
resolve_ssl_version,
|
61 |
-
ssl_wrap_socket,
|
62 |
-
)
|
63 |
-
from .util.ssl_match_hostname import CertificateError, match_hostname
|
64 |
-
|
65 |
-
log = logging.getLogger(__name__)
|
66 |
-
|
67 |
-
port_by_scheme = {"http": 80, "https": 443}
|
68 |
-
|
69 |
-
# When it comes time to update this value as a part of regular maintenance
|
70 |
-
# (ie test_recent_date is failing) update it to ~6 months before the current date.
|
71 |
-
RECENT_DATE = datetime.date(2022, 1, 1)
|
72 |
-
|
73 |
-
_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")
|
74 |
-
|
75 |
-
|
76 |
-
class HTTPConnection(_HTTPConnection, object):
|
77 |
-
"""
|
78 |
-
Based on :class:`http.client.HTTPConnection` but provides an extra constructor
|
79 |
-
backwards-compatibility layer between older and newer Pythons.
|
80 |
-
|
81 |
-
Additional keyword parameters are used to configure attributes of the connection.
|
82 |
-
Accepted parameters include:
|
83 |
-
|
84 |
-
- ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
|
85 |
-
- ``source_address``: Set the source address for the current connection.
|
86 |
-
- ``socket_options``: Set specific options on the underlying socket. If not specified, then
|
87 |
-
defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
|
88 |
-
Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.
|
89 |
-
|
90 |
-
For example, if you wish to enable TCP Keep Alive in addition to the defaults,
|
91 |
-
you might pass:
|
92 |
-
|
93 |
-
.. code-block:: python
|
94 |
-
|
95 |
-
HTTPConnection.default_socket_options + [
|
96 |
-
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
|
97 |
-
]
|
98 |
-
|
99 |
-
Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
|
100 |
-
"""
|
101 |
-
|
102 |
-
default_port = port_by_scheme["http"]
|
103 |
-
|
104 |
-
#: Disable Nagle's algorithm by default.
|
105 |
-
#: ``[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]``
|
106 |
-
default_socket_options = [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]
|
107 |
-
|
108 |
-
#: Whether this connection verifies the host's certificate.
|
109 |
-
is_verified = False
|
110 |
-
|
111 |
-
#: Whether this proxy connection (if used) verifies the proxy host's
|
112 |
-
#: certificate.
|
113 |
-
proxy_is_verified = None
|
114 |
-
|
115 |
-
def __init__(self, *args, **kw):
|
116 |
-
if not six.PY2:
|
117 |
-
kw.pop("strict", None)
|
118 |
-
|
119 |
-
# Pre-set source_address.
|
120 |
-
self.source_address = kw.get("source_address")
|
121 |
-
|
122 |
-
#: The socket options provided by the user. If no options are
|
123 |
-
#: provided, we use the default options.
|
124 |
-
self.socket_options = kw.pop("socket_options", self.default_socket_options)
|
125 |
-
|
126 |
-
# Proxy options provided by the user.
|
127 |
-
self.proxy = kw.pop("proxy", None)
|
128 |
-
self.proxy_config = kw.pop("proxy_config", None)
|
129 |
-
|
130 |
-
_HTTPConnection.__init__(self, *args, **kw)
|
131 |
-
|
132 |
-
@property
|
133 |
-
def host(self):
|
134 |
-
"""
|
135 |
-
Getter method to remove any trailing dots that indicate the hostname is an FQDN.
|
136 |
-
|
137 |
-
In general, SSL certificates don't include the trailing dot indicating a
|
138 |
-
fully-qualified domain name, and thus, they don't validate properly when
|
139 |
-
checked against a domain name that includes the dot. In addition, some
|
140 |
-
servers may not expect to receive the trailing dot when provided.
|
141 |
-
|
142 |
-
However, the hostname with trailing dot is critical to DNS resolution; doing a
|
143 |
-
lookup with the trailing dot will properly only resolve the appropriate FQDN,
|
144 |
-
whereas a lookup without a trailing dot will search the system's search domain
|
145 |
-
list. Thus, it's important to keep the original host around for use only in
|
146 |
-
those cases where it's appropriate (i.e., when doing DNS lookup to establish the
|
147 |
-
actual TCP connection across which we're going to send HTTP requests).
|
148 |
-
"""
|
149 |
-
return self._dns_host.rstrip(".")
|
150 |
-
|
151 |
-
@host.setter
|
152 |
-
def host(self, value):
|
153 |
-
"""
|
154 |
-
Setter for the `host` property.
|
155 |
-
|
156 |
-
We assume that only urllib3 uses the _dns_host attribute; httplib itself
|
157 |
-
only uses `host`, and it seems reasonable that other libraries follow suit.
|
158 |
-
"""
|
159 |
-
self._dns_host = value
|
160 |
-
|
161 |
-
def _new_conn(self):
|
162 |
-
"""Establish a socket connection and set nodelay settings on it.
|
163 |
-
|
164 |
-
:return: New socket connection.
|
165 |
-
"""
|
166 |
-
extra_kw = {}
|
167 |
-
if self.source_address:
|
168 |
-
extra_kw["source_address"] = self.source_address
|
169 |
-
|
170 |
-
if self.socket_options:
|
171 |
-
extra_kw["socket_options"] = self.socket_options
|
172 |
-
|
173 |
-
try:
|
174 |
-
conn = connection.create_connection(
|
175 |
-
(self._dns_host, self.port), self.timeout, **extra_kw
|
176 |
-
)
|
177 |
-
|
178 |
-
except SocketTimeout:
|
179 |
-
raise ConnectTimeoutError(
|
180 |
-
self,
|
181 |
-
"Connection to %s timed out. (connect timeout=%s)"
|
182 |
-
% (self.host, self.timeout),
|
183 |
-
)
|
184 |
-
|
185 |
-
except SocketError as e:
|
186 |
-
raise NewConnectionError(
|
187 |
-
self, "Failed to establish a new connection: %s" % e
|
188 |
-
)
|
189 |
-
|
190 |
-
return conn
|
191 |
-
|
192 |
-
def _is_using_tunnel(self):
|
193 |
-
# Google App Engine's httplib does not define _tunnel_host
|
194 |
-
return getattr(self, "_tunnel_host", None)
|
195 |
-
|
196 |
-
def _prepare_conn(self, conn):
|
197 |
-
self.sock = conn
|
198 |
-
if self._is_using_tunnel():
|
199 |
-
# TODO: Fix tunnel so it doesn't depend on self.sock state.
|
200 |
-
self._tunnel()
|
201 |
-
# Mark this connection as not reusable
|
202 |
-
self.auto_open = 0
|
203 |
-
|
204 |
-
def connect(self):
|
205 |
-
conn = self._new_conn()
|
206 |
-
self._prepare_conn(conn)
|
207 |
-
|
208 |
-
def putrequest(self, method, url, *args, **kwargs):
|
209 |
-
""" """
|
210 |
-
# Empty docstring because the indentation of CPython's implementation
|
211 |
-
# is broken but we don't want this method in our documentation.
|
212 |
-
match = _CONTAINS_CONTROL_CHAR_RE.search(method)
|
213 |
-
if match:
|
214 |
-
raise ValueError(
|
215 |
-
"Method cannot contain non-token characters %r (found at least %r)"
|
216 |
-
% (method, match.group())
|
217 |
-
)
|
218 |
-
|
219 |
-
return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
|
220 |
-
|
221 |
-
def putheader(self, header, *values):
|
222 |
-
""" """
|
223 |
-
if not any(isinstance(v, str) and v == SKIP_HEADER for v in values):
|
224 |
-
_HTTPConnection.putheader(self, header, *values)
|
225 |
-
elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS:
|
226 |
-
raise ValueError(
|
227 |
-
"urllib3.util.SKIP_HEADER only supports '%s'"
|
228 |
-
% ("', '".join(map(str.title, sorted(SKIPPABLE_HEADERS))),)
|
229 |
-
)
|
230 |
-
|
231 |
-
def request(self, method, url, body=None, headers=None):
|
232 |
-
# Update the inner socket's timeout value to send the request.
|
233 |
-
# This only triggers if the connection is re-used.
|
234 |
-
if getattr(self, "sock", None) is not None:
|
235 |
-
self.sock.settimeout(self.timeout)
|
236 |
-
|
237 |
-
if headers is None:
|
238 |
-
headers = {}
|
239 |
-
else:
|
240 |
-
# Avoid modifying the headers passed into .request()
|
241 |
-
headers = headers.copy()
|
242 |
-
if "user-agent" not in (six.ensure_str(k.lower()) for k in headers):
|
243 |
-
headers["User-Agent"] = _get_default_user_agent()
|
244 |
-
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
|
245 |
-
|
246 |
-
def request_chunked(self, method, url, body=None, headers=None):
|
247 |
-
"""
|
248 |
-
Alternative to the common request method, which sends the
|
249 |
-
body with chunked encoding and not as one block
|
250 |
-
"""
|
251 |
-
headers = headers or {}
|
252 |
-
header_keys = set([six.ensure_str(k.lower()) for k in headers])
|
253 |
-
skip_accept_encoding = "accept-encoding" in header_keys
|
254 |
-
skip_host = "host" in header_keys
|
255 |
-
self.putrequest(
|
256 |
-
method, url, skip_accept_encoding=skip_accept_encoding, skip_host=skip_host
|
257 |
-
)
|
258 |
-
if "user-agent" not in header_keys:
|
259 |
-
self.putheader("User-Agent", _get_default_user_agent())
|
260 |
-
for header, value in headers.items():
|
261 |
-
self.putheader(header, value)
|
262 |
-
if "transfer-encoding" not in header_keys:
|
263 |
-
self.putheader("Transfer-Encoding", "chunked")
|
264 |
-
self.endheaders()
|
265 |
-
|
266 |
-
if body is not None:
|
267 |
-
stringish_types = six.string_types + (bytes,)
|
268 |
-
if isinstance(body, stringish_types):
|
269 |
-
body = (body,)
|
270 |
-
for chunk in body:
|
271 |
-
if not chunk:
|
272 |
-
continue
|
273 |
-
if not isinstance(chunk, bytes):
|
274 |
-
chunk = chunk.encode("utf8")
|
275 |
-
len_str = hex(len(chunk))[2:]
|
276 |
-
to_send = bytearray(len_str.encode())
|
277 |
-
to_send += b"\r\n"
|
278 |
-
to_send += chunk
|
279 |
-
to_send += b"\r\n"
|
280 |
-
self.send(to_send)
|
281 |
-
|
282 |
-
# After the if clause, to always have a closed body
|
283 |
-
self.send(b"0\r\n\r\n")
|
284 |
-
|
285 |
-
|
286 |
-
class HTTPSConnection(HTTPConnection):
|
287 |
-
"""
|
288 |
-
Many of the parameters to this constructor are passed to the underlying SSL
|
289 |
-
socket by means of :py:func:`urllib3.util.ssl_wrap_socket`.
|
290 |
-
"""
|
291 |
-
|
292 |
-
default_port = port_by_scheme["https"]
|
293 |
-
|
294 |
-
cert_reqs = None
|
295 |
-
ca_certs = None
|
296 |
-
ca_cert_dir = None
|
297 |
-
ca_cert_data = None
|
298 |
-
ssl_version = None
|
299 |
-
assert_fingerprint = None
|
300 |
-
tls_in_tls_required = False
|
301 |
-
|
302 |
-
def __init__(
|
303 |
-
self,
|
304 |
-
host,
|
305 |
-
port=None,
|
306 |
-
key_file=None,
|
307 |
-
cert_file=None,
|
308 |
-
key_password=None,
|
309 |
-
strict=None,
|
310 |
-
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
311 |
-
ssl_context=None,
|
312 |
-
server_hostname=None,
|
313 |
-
**kw
|
314 |
-
):
|
315 |
-
|
316 |
-
HTTPConnection.__init__(self, host, port, strict=strict, timeout=timeout, **kw)
|
317 |
-
|
318 |
-
self.key_file = key_file
|
319 |
-
self.cert_file = cert_file
|
320 |
-
self.key_password = key_password
|
321 |
-
self.ssl_context = ssl_context
|
322 |
-
self.server_hostname = server_hostname
|
323 |
-
|
324 |
-
# Required property for Google AppEngine 1.9.0 which otherwise causes
|
325 |
-
# HTTPS requests to go out as HTTP. (See Issue #356)
|
326 |
-
self._protocol = "https"
|
327 |
-
|
328 |
-
def set_cert(
|
329 |
-
self,
|
330 |
-
key_file=None,
|
331 |
-
cert_file=None,
|
332 |
-
cert_reqs=None,
|
333 |
-
key_password=None,
|
334 |
-
ca_certs=None,
|
335 |
-
assert_hostname=None,
|
336 |
-
assert_fingerprint=None,
|
337 |
-
ca_cert_dir=None,
|
338 |
-
ca_cert_data=None,
|
339 |
-
):
|
340 |
-
"""
|
341 |
-
This method should only be called once, before the connection is used.
|
342 |
-
"""
|
343 |
-
# If cert_reqs is not provided we'll assume CERT_REQUIRED unless we also
|
344 |
-
# have an SSLContext object in which case we'll use its verify_mode.
|
345 |
-
if cert_reqs is None:
|
346 |
-
if self.ssl_context is not None:
|
347 |
-
cert_reqs = self.ssl_context.verify_mode
|
348 |
-
else:
|
349 |
-
cert_reqs = resolve_cert_reqs(None)
|
350 |
-
|
351 |
-
self.key_file = key_file
|
352 |
-
self.cert_file = cert_file
|
353 |
-
self.cert_reqs = cert_reqs
|
354 |
-
self.key_password = key_password
|
355 |
-
self.assert_hostname = assert_hostname
|
356 |
-
self.assert_fingerprint = assert_fingerprint
|
357 |
-
self.ca_certs = ca_certs and os.path.expanduser(ca_certs)
|
358 |
-
self.ca_cert_dir = ca_cert_dir and os.path.expanduser(ca_cert_dir)
|
359 |
-
self.ca_cert_data = ca_cert_data
|
360 |
-
|
361 |
-
def connect(self):
|
362 |
-
# Add certificate verification
|
363 |
-
self.sock = conn = self._new_conn()
|
364 |
-
hostname = self.host
|
365 |
-
tls_in_tls = False
|
366 |
-
|
367 |
-
if self._is_using_tunnel():
|
368 |
-
if self.tls_in_tls_required:
|
369 |
-
self.sock = conn = self._connect_tls_proxy(hostname, conn)
|
370 |
-
tls_in_tls = True
|
371 |
-
|
372 |
-
# Calls self._set_hostport(), so self.host is
|
373 |
-
# self._tunnel_host below.
|
374 |
-
self._tunnel()
|
375 |
-
# Mark this connection as not reusable
|
376 |
-
self.auto_open = 0
|
377 |
-
|
378 |
-
# Override the host with the one we're requesting data from.
|
379 |
-
hostname = self._tunnel_host
|
380 |
-
|
381 |
-
server_hostname = hostname
|
382 |
-
if self.server_hostname is not None:
|
383 |
-
server_hostname = self.server_hostname
|
384 |
-
|
385 |
-
is_time_off = datetime.date.today() < RECENT_DATE
|
386 |
-
if is_time_off:
|
387 |
-
warnings.warn(
|
388 |
-
(
|
389 |
-
"System time is way off (before {0}). This will probably "
|
390 |
-
"lead to SSL verification errors"
|
391 |
-
).format(RECENT_DATE),
|
392 |
-
SystemTimeWarning,
|
393 |
-
)
|
394 |
-
|
395 |
-
# Wrap socket using verification with the root certs in
|
396 |
-
# trusted_root_certs
|
397 |
-
default_ssl_context = False
|
398 |
-
if self.ssl_context is None:
|
399 |
-
default_ssl_context = True
|
400 |
-
self.ssl_context = create_urllib3_context(
|
401 |
-
ssl_version=resolve_ssl_version(self.ssl_version),
|
402 |
-
cert_reqs=resolve_cert_reqs(self.cert_reqs),
|
403 |
-
)
|
404 |
-
|
405 |
-
context = self.ssl_context
|
406 |
-
context.verify_mode = resolve_cert_reqs(self.cert_reqs)
|
407 |
-
|
408 |
-
# Try to load OS default certs if none are given.
|
409 |
-
# Works well on Windows (requires Python3.4+)
|
410 |
-
if (
|
411 |
-
not self.ca_certs
|
412 |
-
and not self.ca_cert_dir
|
413 |
-
and not self.ca_cert_data
|
414 |
-
and default_ssl_context
|
415 |
-
and hasattr(context, "load_default_certs")
|
416 |
-
):
|
417 |
-
context.load_default_certs()
|
418 |
-
|
419 |
-
self.sock = ssl_wrap_socket(
|
420 |
-
sock=conn,
|
421 |
-
keyfile=self.key_file,
|
422 |
-
certfile=self.cert_file,
|
423 |
-
key_password=self.key_password,
|
424 |
-
ca_certs=self.ca_certs,
|
425 |
-
ca_cert_dir=self.ca_cert_dir,
|
426 |
-
ca_cert_data=self.ca_cert_data,
|
427 |
-
server_hostname=server_hostname,
|
428 |
-
ssl_context=context,
|
429 |
-
tls_in_tls=tls_in_tls,
|
430 |
-
)
|
431 |
-
|
432 |
-
# If we're using all defaults and the connection
|
433 |
-
# is TLSv1 or TLSv1.1 we throw a DeprecationWarning
|
434 |
-
# for the host.
|
435 |
-
if (
|
436 |
-
default_ssl_context
|
437 |
-
and self.ssl_version is None
|
438 |
-
and hasattr(self.sock, "version")
|
439 |
-
and self.sock.version() in {"TLSv1", "TLSv1.1"}
|
440 |
-
):
|
441 |
-
warnings.warn(
|
442 |
-
"Negotiating TLSv1/TLSv1.1 by default is deprecated "
|
443 |
-
"and will be disabled in urllib3 v2.0.0. Connecting to "
|
444 |
-
"'%s' with '%s' can be enabled by explicitly opting-in "
|
445 |
-
"with 'ssl_version'" % (self.host, self.sock.version()),
|
446 |
-
DeprecationWarning,
|
447 |
-
)
|
448 |
-
|
449 |
-
if self.assert_fingerprint:
|
450 |
-
assert_fingerprint(
|
451 |
-
self.sock.getpeercert(binary_form=True), self.assert_fingerprint
|
452 |
-
)
|
453 |
-
elif (
|
454 |
-
context.verify_mode != ssl.CERT_NONE
|
455 |
-
and not getattr(context, "check_hostname", False)
|
456 |
-
and self.assert_hostname is not False
|
457 |
-
):
|
458 |
-
# While urllib3 attempts to always turn off hostname matching from
|
459 |
-
# the TLS library, this cannot always be done. So we check whether
|
460 |
-
# the TLS Library still thinks it's matching hostnames.
|
461 |
-
cert = self.sock.getpeercert()
|
462 |
-
if not cert.get("subjectAltName", ()):
|
463 |
-
warnings.warn(
|
464 |
-
(
|
465 |
-
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
|
466 |
-
"`commonName` for now. This feature is being removed by major browsers and "
|
467 |
-
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
|
468 |
-
"for details.)".format(hostname)
|
469 |
-
),
|
470 |
-
SubjectAltNameWarning,
|
471 |
-
)
|
472 |
-
_match_hostname(cert, self.assert_hostname or server_hostname)
|
473 |
-
|
474 |
-
self.is_verified = (
|
475 |
-
context.verify_mode == ssl.CERT_REQUIRED
|
476 |
-
or self.assert_fingerprint is not None
|
477 |
-
)
|
478 |
-
|
479 |
-
def _connect_tls_proxy(self, hostname, conn):
|
480 |
-
"""
|
481 |
-
Establish a TLS connection to the proxy using the provided SSL context.
|
482 |
-
"""
|
483 |
-
proxy_config = self.proxy_config
|
484 |
-
ssl_context = proxy_config.ssl_context
|
485 |
-
if ssl_context:
|
486 |
-
# If the user provided a proxy context, we assume CA and client
|
487 |
-
# certificates have already been set
|
488 |
-
return ssl_wrap_socket(
|
489 |
-
sock=conn,
|
490 |
-
server_hostname=hostname,
|
491 |
-
ssl_context=ssl_context,
|
492 |
-
)
|
493 |
-
|
494 |
-
ssl_context = create_proxy_ssl_context(
|
495 |
-
self.ssl_version,
|
496 |
-
self.cert_reqs,
|
497 |
-
self.ca_certs,
|
498 |
-
self.ca_cert_dir,
|
499 |
-
self.ca_cert_data,
|
500 |
-
)
|
501 |
-
|
502 |
-
# If no cert was provided, use only the default options for server
|
503 |
-
# certificate validation
|
504 |
-
socket = ssl_wrap_socket(
|
505 |
-
sock=conn,
|
506 |
-
ca_certs=self.ca_certs,
|
507 |
-
ca_cert_dir=self.ca_cert_dir,
|
508 |
-
ca_cert_data=self.ca_cert_data,
|
509 |
-
server_hostname=hostname,
|
510 |
-
ssl_context=ssl_context,
|
511 |
-
)
|
512 |
-
|
513 |
-
if ssl_context.verify_mode != ssl.CERT_NONE and not getattr(
|
514 |
-
ssl_context, "check_hostname", False
|
515 |
-
):
|
516 |
-
# While urllib3 attempts to always turn off hostname matching from
|
517 |
-
# the TLS library, this cannot always be done. So we check whether
|
518 |
-
# the TLS Library still thinks it's matching hostnames.
|
519 |
-
cert = socket.getpeercert()
|
520 |
-
if not cert.get("subjectAltName", ()):
|
521 |
-
warnings.warn(
|
522 |
-
(
|
523 |
-
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
|
524 |
-
"`commonName` for now. This feature is being removed by major browsers and "
|
525 |
-
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
|
526 |
-
"for details.)".format(hostname)
|
527 |
-
),
|
528 |
-
SubjectAltNameWarning,
|
529 |
-
)
|
530 |
-
_match_hostname(cert, hostname)
|
531 |
-
|
532 |
-
self.proxy_is_verified = ssl_context.verify_mode == ssl.CERT_REQUIRED
|
533 |
-
return socket
|
534 |
-
|
535 |
-
|
536 |
-
def _match_hostname(cert, asserted_hostname):
|
537 |
-
# Our upstream implementation of ssl.match_hostname()
|
538 |
-
# only applies this normalization to IP addresses so it doesn't
|
539 |
-
# match DNS SANs so we do the same thing!
|
540 |
-
stripped_hostname = asserted_hostname.strip("u[]")
|
541 |
-
if is_ipaddress(stripped_hostname):
|
542 |
-
asserted_hostname = stripped_hostname
|
543 |
-
|
544 |
-
try:
|
545 |
-
match_hostname(cert, asserted_hostname)
|
546 |
-
except CertificateError as e:
|
547 |
-
log.warning(
|
548 |
-
"Certificate did not match expected hostname: %s. Certificate: %s",
|
549 |
-
asserted_hostname,
|
550 |
-
cert,
|
551 |
-
)
|
552 |
-
# Add cert to exception and reraise so client code can inspect
|
553 |
-
# the cert when catching the exception, if they want to
|
554 |
-
e._peer_cert = cert
|
555 |
-
raise
|
556 |
-
|
557 |
-
|
558 |
-
def _get_default_user_agent():
|
559 |
-
return "python-urllib3/%s" % __version__
|
560 |
-
|
561 |
-
|
562 |
-
class DummyConnection(object):
|
563 |
-
"""Used to detect a failed ConnectionCls import."""
|
564 |
-
|
565 |
-
pass
|
566 |
-
|
567 |
-
|
568 |
-
if not ssl:
|
569 |
-
HTTPSConnection = DummyConnection # noqa: F811
|
570 |
-
|
571 |
-
|
572 |
-
VerifiedHTTPSConnection = HTTPSConnection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/setuptools/_distutils/_msvccompiler.py
DELETED
@@ -1,572 +0,0 @@
|
|
1 |
-
"""distutils._msvccompiler
|
2 |
-
|
3 |
-
Contains MSVCCompiler, an implementation of the abstract CCompiler class
|
4 |
-
for Microsoft Visual Studio 2015.
|
5 |
-
|
6 |
-
The module is compatible with VS 2015 and later. You can find legacy support
|
7 |
-
for older versions in distutils.msvc9compiler and distutils.msvccompiler.
|
8 |
-
"""
|
9 |
-
|
10 |
-
# Written by Perry Stoll
|
11 |
-
# hacked by Robin Becker and Thomas Heller to do a better job of
|
12 |
-
# finding DevStudio (through the registry)
|
13 |
-
# ported to VS 2005 and VS 2008 by Christian Heimes
|
14 |
-
# ported to VS 2015 by Steve Dower
|
15 |
-
|
16 |
-
import os
|
17 |
-
import subprocess
|
18 |
-
import contextlib
|
19 |
-
import warnings
|
20 |
-
import unittest.mock as mock
|
21 |
-
|
22 |
-
with contextlib.suppress(ImportError):
|
23 |
-
import winreg
|
24 |
-
|
25 |
-
from distutils.errors import (
|
26 |
-
DistutilsExecError,
|
27 |
-
DistutilsPlatformError,
|
28 |
-
CompileError,
|
29 |
-
LibError,
|
30 |
-
LinkError,
|
31 |
-
)
|
32 |
-
from distutils.ccompiler import CCompiler, gen_lib_options
|
33 |
-
from distutils import log
|
34 |
-
from distutils.util import get_platform
|
35 |
-
|
36 |
-
from itertools import count
|
37 |
-
|
38 |
-
|
39 |
-
def _find_vc2015():
|
40 |
-
try:
|
41 |
-
key = winreg.OpenKeyEx(
|
42 |
-
winreg.HKEY_LOCAL_MACHINE,
|
43 |
-
r"Software\Microsoft\VisualStudio\SxS\VC7",
|
44 |
-
access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY,
|
45 |
-
)
|
46 |
-
except OSError:
|
47 |
-
log.debug("Visual C++ is not registered")
|
48 |
-
return None, None
|
49 |
-
|
50 |
-
best_version = 0
|
51 |
-
best_dir = None
|
52 |
-
with key:
|
53 |
-
for i in count():
|
54 |
-
try:
|
55 |
-
v, vc_dir, vt = winreg.EnumValue(key, i)
|
56 |
-
except OSError:
|
57 |
-
break
|
58 |
-
if v and vt == winreg.REG_SZ and os.path.isdir(vc_dir):
|
59 |
-
try:
|
60 |
-
version = int(float(v))
|
61 |
-
except (ValueError, TypeError):
|
62 |
-
continue
|
63 |
-
if version >= 14 and version > best_version:
|
64 |
-
best_version, best_dir = version, vc_dir
|
65 |
-
return best_version, best_dir
|
66 |
-
|
67 |
-
|
68 |
-
def _find_vc2017():
|
69 |
-
"""Returns "15, path" based on the result of invoking vswhere.exe
|
70 |
-
If no install is found, returns "None, None"
|
71 |
-
|
72 |
-
The version is returned to avoid unnecessarily changing the function
|
73 |
-
result. It may be ignored when the path is not None.
|
74 |
-
|
75 |
-
If vswhere.exe is not available, by definition, VS 2017 is not
|
76 |
-
installed.
|
77 |
-
"""
|
78 |
-
root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")
|
79 |
-
if not root:
|
80 |
-
return None, None
|
81 |
-
|
82 |
-
try:
|
83 |
-
path = subprocess.check_output(
|
84 |
-
[
|
85 |
-
os.path.join(
|
86 |
-
root, "Microsoft Visual Studio", "Installer", "vswhere.exe"
|
87 |
-
),
|
88 |
-
"-latest",
|
89 |
-
"-prerelease",
|
90 |
-
"-requires",
|
91 |
-
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
92 |
-
"-property",
|
93 |
-
"installationPath",
|
94 |
-
"-products",
|
95 |
-
"*",
|
96 |
-
],
|
97 |
-
encoding="mbcs",
|
98 |
-
errors="strict",
|
99 |
-
).strip()
|
100 |
-
except (subprocess.CalledProcessError, OSError, UnicodeDecodeError):
|
101 |
-
return None, None
|
102 |
-
|
103 |
-
path = os.path.join(path, "VC", "Auxiliary", "Build")
|
104 |
-
if os.path.isdir(path):
|
105 |
-
return 15, path
|
106 |
-
|
107 |
-
return None, None
|
108 |
-
|
109 |
-
|
110 |
-
PLAT_SPEC_TO_RUNTIME = {
|
111 |
-
'x86': 'x86',
|
112 |
-
'x86_amd64': 'x64',
|
113 |
-
'x86_arm': 'arm',
|
114 |
-
'x86_arm64': 'arm64',
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
def _find_vcvarsall(plat_spec):
|
119 |
-
# bpo-38597: Removed vcruntime return value
|
120 |
-
_, best_dir = _find_vc2017()
|
121 |
-
|
122 |
-
if not best_dir:
|
123 |
-
best_version, best_dir = _find_vc2015()
|
124 |
-
|
125 |
-
if not best_dir:
|
126 |
-
log.debug("No suitable Visual C++ version found")
|
127 |
-
return None, None
|
128 |
-
|
129 |
-
vcvarsall = os.path.join(best_dir, "vcvarsall.bat")
|
130 |
-
if not os.path.isfile(vcvarsall):
|
131 |
-
log.debug("%s cannot be found", vcvarsall)
|
132 |
-
return None, None
|
133 |
-
|
134 |
-
return vcvarsall, None
|
135 |
-
|
136 |
-
|
137 |
-
def _get_vc_env(plat_spec):
|
138 |
-
if os.getenv("DISTUTILS_USE_SDK"):
|
139 |
-
return {key.lower(): value for key, value in os.environ.items()}
|
140 |
-
|
141 |
-
vcvarsall, _ = _find_vcvarsall(plat_spec)
|
142 |
-
if not vcvarsall:
|
143 |
-
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
|
144 |
-
|
145 |
-
try:
|
146 |
-
out = subprocess.check_output(
|
147 |
-
f'cmd /u /c "{vcvarsall}" {plat_spec} && set',
|
148 |
-
stderr=subprocess.STDOUT,
|
149 |
-
).decode('utf-16le', errors='replace')
|
150 |
-
except subprocess.CalledProcessError as exc:
|
151 |
-
log.error(exc.output)
|
152 |
-
raise DistutilsPlatformError(f"Error executing {exc.cmd}")
|
153 |
-
|
154 |
-
env = {
|
155 |
-
key.lower(): value
|
156 |
-
for key, _, value in (line.partition('=') for line in out.splitlines())
|
157 |
-
if key and value
|
158 |
-
}
|
159 |
-
|
160 |
-
return env
|
161 |
-
|
162 |
-
|
163 |
-
def _find_exe(exe, paths=None):
|
164 |
-
"""Return path to an MSVC executable program.
|
165 |
-
|
166 |
-
Tries to find the program in several places: first, one of the
|
167 |
-
MSVC program search paths from the registry; next, the directories
|
168 |
-
in the PATH environment variable. If any of those work, return an
|
169 |
-
absolute path that is known to exist. If none of them work, just
|
170 |
-
return the original program name, 'exe'.
|
171 |
-
"""
|
172 |
-
if not paths:
|
173 |
-
paths = os.getenv('path').split(os.pathsep)
|
174 |
-
for p in paths:
|
175 |
-
fn = os.path.join(os.path.abspath(p), exe)
|
176 |
-
if os.path.isfile(fn):
|
177 |
-
return fn
|
178 |
-
return exe
|
179 |
-
|
180 |
-
|
181 |
-
# A map keyed by get_platform() return values to values accepted by
|
182 |
-
# 'vcvarsall.bat'. Always cross-compile from x86 to work with the
|
183 |
-
# lighter-weight MSVC installs that do not include native 64-bit tools.
|
184 |
-
PLAT_TO_VCVARS = {
|
185 |
-
'win32': 'x86',
|
186 |
-
'win-amd64': 'x86_amd64',
|
187 |
-
'win-arm32': 'x86_arm',
|
188 |
-
'win-arm64': 'x86_arm64',
|
189 |
-
}
|
190 |
-
|
191 |
-
|
192 |
-
class MSVCCompiler(CCompiler):
|
193 |
-
"""Concrete class that implements an interface to Microsoft Visual C++,
|
194 |
-
as defined by the CCompiler abstract class."""
|
195 |
-
|
196 |
-
compiler_type = 'msvc'
|
197 |
-
|
198 |
-
# Just set this so CCompiler's constructor doesn't barf. We currently
|
199 |
-
# don't use the 'set_executables()' bureaucracy provided by CCompiler,
|
200 |
-
# as it really isn't necessary for this sort of single-compiler class.
|
201 |
-
# Would be nice to have a consistent interface with UnixCCompiler,
|
202 |
-
# though, so it's worth thinking about.
|
203 |
-
executables = {}
|
204 |
-
|
205 |
-
# Private class data (need to distinguish C from C++ source for compiler)
|
206 |
-
_c_extensions = ['.c']
|
207 |
-
_cpp_extensions = ['.cc', '.cpp', '.cxx']
|
208 |
-
_rc_extensions = ['.rc']
|
209 |
-
_mc_extensions = ['.mc']
|
210 |
-
|
211 |
-
# Needed for the filename generation methods provided by the
|
212 |
-
# base class, CCompiler.
|
213 |
-
src_extensions = _c_extensions + _cpp_extensions + _rc_extensions + _mc_extensions
|
214 |
-
res_extension = '.res'
|
215 |
-
obj_extension = '.obj'
|
216 |
-
static_lib_extension = '.lib'
|
217 |
-
shared_lib_extension = '.dll'
|
218 |
-
static_lib_format = shared_lib_format = '%s%s'
|
219 |
-
exe_extension = '.exe'
|
220 |
-
|
221 |
-
def __init__(self, verbose=0, dry_run=0, force=0):
|
222 |
-
super().__init__(verbose, dry_run, force)
|
223 |
-
# target platform (.plat_name is consistent with 'bdist')
|
224 |
-
self.plat_name = None
|
225 |
-
self.initialized = False
|
226 |
-
|
227 |
-
@classmethod
|
228 |
-
def _configure(cls, vc_env):
|
229 |
-
"""
|
230 |
-
Set class-level include/lib dirs.
|
231 |
-
"""
|
232 |
-
cls.include_dirs = cls._parse_path(vc_env.get('include', ''))
|
233 |
-
cls.library_dirs = cls._parse_path(vc_env.get('lib', ''))
|
234 |
-
|
235 |
-
@staticmethod
|
236 |
-
def _parse_path(val):
|
237 |
-
return [dir.rstrip(os.sep) for dir in val.split(os.pathsep) if dir]
|
238 |
-
|
239 |
-
def initialize(self, plat_name=None):
|
240 |
-
# multi-init means we would need to check platform same each time...
|
241 |
-
assert not self.initialized, "don't init multiple times"
|
242 |
-
if plat_name is None:
|
243 |
-
plat_name = get_platform()
|
244 |
-
# sanity check for platforms to prevent obscure errors later.
|
245 |
-
if plat_name not in PLAT_TO_VCVARS:
|
246 |
-
raise DistutilsPlatformError(
|
247 |
-
f"--plat-name must be one of {tuple(PLAT_TO_VCVARS)}"
|
248 |
-
)
|
249 |
-
|
250 |
-
# Get the vcvarsall.bat spec for the requested platform.
|
251 |
-
plat_spec = PLAT_TO_VCVARS[plat_name]
|
252 |
-
|
253 |
-
vc_env = _get_vc_env(plat_spec)
|
254 |
-
if not vc_env:
|
255 |
-
raise DistutilsPlatformError(
|
256 |
-
"Unable to find a compatible " "Visual Studio installation."
|
257 |
-
)
|
258 |
-
self._configure(vc_env)
|
259 |
-
|
260 |
-
self._paths = vc_env.get('path', '')
|
261 |
-
paths = self._paths.split(os.pathsep)
|
262 |
-
self.cc = _find_exe("cl.exe", paths)
|
263 |
-
self.linker = _find_exe("link.exe", paths)
|
264 |
-
self.lib = _find_exe("lib.exe", paths)
|
265 |
-
self.rc = _find_exe("rc.exe", paths) # resource compiler
|
266 |
-
self.mc = _find_exe("mc.exe", paths) # message compiler
|
267 |
-
self.mt = _find_exe("mt.exe", paths) # message compiler
|
268 |
-
|
269 |
-
self.preprocess_options = None
|
270 |
-
# bpo-38597: Always compile with dynamic linking
|
271 |
-
# Future releases of Python 3.x will include all past
|
272 |
-
# versions of vcruntime*.dll for compatibility.
|
273 |
-
self.compile_options = ['/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD']
|
274 |
-
|
275 |
-
self.compile_options_debug = [
|
276 |
-
'/nologo',
|
277 |
-
'/Od',
|
278 |
-
'/MDd',
|
279 |
-
'/Zi',
|
280 |
-
'/W3',
|
281 |
-
'/D_DEBUG',
|
282 |
-
]
|
283 |
-
|
284 |
-
ldflags = ['/nologo', '/INCREMENTAL:NO', '/LTCG']
|
285 |
-
|
286 |
-
ldflags_debug = ['/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL']
|
287 |
-
|
288 |
-
self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1']
|
289 |
-
self.ldflags_exe_debug = [*ldflags_debug, '/MANIFEST:EMBED,ID=1']
|
290 |
-
self.ldflags_shared = [
|
291 |
-
*ldflags,
|
292 |
-
'/DLL',
|
293 |
-
'/MANIFEST:EMBED,ID=2',
|
294 |
-
'/MANIFESTUAC:NO',
|
295 |
-
]
|
296 |
-
self.ldflags_shared_debug = [
|
297 |
-
*ldflags_debug,
|
298 |
-
'/DLL',
|
299 |
-
'/MANIFEST:EMBED,ID=2',
|
300 |
-
'/MANIFESTUAC:NO',
|
301 |
-
]
|
302 |
-
self.ldflags_static = [*ldflags]
|
303 |
-
self.ldflags_static_debug = [*ldflags_debug]
|
304 |
-
|
305 |
-
self._ldflags = {
|
306 |
-
(CCompiler.EXECUTABLE, None): self.ldflags_exe,
|
307 |
-
(CCompiler.EXECUTABLE, False): self.ldflags_exe,
|
308 |
-
(CCompiler.EXECUTABLE, True): self.ldflags_exe_debug,
|
309 |
-
(CCompiler.SHARED_OBJECT, None): self.ldflags_shared,
|
310 |
-
(CCompiler.SHARED_OBJECT, False): self.ldflags_shared,
|
311 |
-
(CCompiler.SHARED_OBJECT, True): self.ldflags_shared_debug,
|
312 |
-
(CCompiler.SHARED_LIBRARY, None): self.ldflags_static,
|
313 |
-
(CCompiler.SHARED_LIBRARY, False): self.ldflags_static,
|
314 |
-
(CCompiler.SHARED_LIBRARY, True): self.ldflags_static_debug,
|
315 |
-
}
|
316 |
-
|
317 |
-
self.initialized = True
|
318 |
-
|
319 |
-
# -- Worker methods ------------------------------------------------
|
320 |
-
|
321 |
-
@property
|
322 |
-
def out_extensions(self):
|
323 |
-
return {
|
324 |
-
**super().out_extensions,
|
325 |
-
**{
|
326 |
-
ext: self.res_extension
|
327 |
-
for ext in self._rc_extensions + self._mc_extensions
|
328 |
-
},
|
329 |
-
}
|
330 |
-
|
331 |
-
def compile( # noqa: C901
|
332 |
-
self,
|
333 |
-
sources,
|
334 |
-
output_dir=None,
|
335 |
-
macros=None,
|
336 |
-
include_dirs=None,
|
337 |
-
debug=0,
|
338 |
-
extra_preargs=None,
|
339 |
-
extra_postargs=None,
|
340 |
-
depends=None,
|
341 |
-
):
|
342 |
-
|
343 |
-
if not self.initialized:
|
344 |
-
self.initialize()
|
345 |
-
compile_info = self._setup_compile(
|
346 |
-
output_dir, macros, include_dirs, sources, depends, extra_postargs
|
347 |
-
)
|
348 |
-
macros, objects, extra_postargs, pp_opts, build = compile_info
|
349 |
-
|
350 |
-
compile_opts = extra_preargs or []
|
351 |
-
compile_opts.append('/c')
|
352 |
-
if debug:
|
353 |
-
compile_opts.extend(self.compile_options_debug)
|
354 |
-
else:
|
355 |
-
compile_opts.extend(self.compile_options)
|
356 |
-
|
357 |
-
add_cpp_opts = False
|
358 |
-
|
359 |
-
for obj in objects:
|
360 |
-
try:
|
361 |
-
src, ext = build[obj]
|
362 |
-
except KeyError:
|
363 |
-
continue
|
364 |
-
if debug:
|
365 |
-
# pass the full pathname to MSVC in debug mode,
|
366 |
-
# this allows the debugger to find the source file
|
367 |
-
# without asking the user to browse for it
|
368 |
-
src = os.path.abspath(src)
|
369 |
-
|
370 |
-
if ext in self._c_extensions:
|
371 |
-
input_opt = "/Tc" + src
|
372 |
-
elif ext in self._cpp_extensions:
|
373 |
-
input_opt = "/Tp" + src
|
374 |
-
add_cpp_opts = True
|
375 |
-
elif ext in self._rc_extensions:
|
376 |
-
# compile .RC to .RES file
|
377 |
-
input_opt = src
|
378 |
-
output_opt = "/fo" + obj
|
379 |
-
try:
|
380 |
-
self.spawn([self.rc] + pp_opts + [output_opt, input_opt])
|
381 |
-
except DistutilsExecError as msg:
|
382 |
-
raise CompileError(msg)
|
383 |
-
continue
|
384 |
-
elif ext in self._mc_extensions:
|
385 |
-
# Compile .MC to .RC file to .RES file.
|
386 |
-
# * '-h dir' specifies the directory for the
|
387 |
-
# generated include file
|
388 |
-
# * '-r dir' specifies the target directory of the
|
389 |
-
# generated RC file and the binary message resource
|
390 |
-
# it includes
|
391 |
-
#
|
392 |
-
# For now (since there are no options to change this),
|
393 |
-
# we use the source-directory for the include file and
|
394 |
-
# the build directory for the RC file and message
|
395 |
-
# resources. This works at least for win32all.
|
396 |
-
h_dir = os.path.dirname(src)
|
397 |
-
rc_dir = os.path.dirname(obj)
|
398 |
-
try:
|
399 |
-
# first compile .MC to .RC and .H file
|
400 |
-
self.spawn([self.mc, '-h', h_dir, '-r', rc_dir, src])
|
401 |
-
base, _ = os.path.splitext(os.path.basename(src))
|
402 |
-
rc_file = os.path.join(rc_dir, base + '.rc')
|
403 |
-
# then compile .RC to .RES file
|
404 |
-
self.spawn([self.rc, "/fo" + obj, rc_file])
|
405 |
-
|
406 |
-
except DistutilsExecError as msg:
|
407 |
-
raise CompileError(msg)
|
408 |
-
continue
|
409 |
-
else:
|
410 |
-
# how to handle this file?
|
411 |
-
raise CompileError(f"Don't know how to compile {src} to {obj}")
|
412 |
-
|
413 |
-
args = [self.cc] + compile_opts + pp_opts
|
414 |
-
if add_cpp_opts:
|
415 |
-
args.append('/EHsc')
|
416 |
-
args.append(input_opt)
|
417 |
-
args.append("/Fo" + obj)
|
418 |
-
args.extend(extra_postargs)
|
419 |
-
|
420 |
-
try:
|
421 |
-
self.spawn(args)
|
422 |
-
except DistutilsExecError as msg:
|
423 |
-
raise CompileError(msg)
|
424 |
-
|
425 |
-
return objects
|
426 |
-
|
427 |
-
def create_static_lib(
|
428 |
-
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
|
429 |
-
):
|
430 |
-
|
431 |
-
if not self.initialized:
|
432 |
-
self.initialize()
|
433 |
-
objects, output_dir = self._fix_object_args(objects, output_dir)
|
434 |
-
output_filename = self.library_filename(output_libname, output_dir=output_dir)
|
435 |
-
|
436 |
-
if self._need_link(objects, output_filename):
|
437 |
-
lib_args = objects + ['/OUT:' + output_filename]
|
438 |
-
if debug:
|
439 |
-
pass # XXX what goes here?
|
440 |
-
try:
|
441 |
-
log.debug('Executing "%s" %s', self.lib, ' '.join(lib_args))
|
442 |
-
self.spawn([self.lib] + lib_args)
|
443 |
-
except DistutilsExecError as msg:
|
444 |
-
raise LibError(msg)
|
445 |
-
else:
|
446 |
-
log.debug("skipping %s (up-to-date)", output_filename)
|
447 |
-
|
448 |
-
def link(
|
449 |
-
self,
|
450 |
-
target_desc,
|
451 |
-
objects,
|
452 |
-
output_filename,
|
453 |
-
output_dir=None,
|
454 |
-
libraries=None,
|
455 |
-
library_dirs=None,
|
456 |
-
runtime_library_dirs=None,
|
457 |
-
export_symbols=None,
|
458 |
-
debug=0,
|
459 |
-
extra_preargs=None,
|
460 |
-
extra_postargs=None,
|
461 |
-
build_temp=None,
|
462 |
-
target_lang=None,
|
463 |
-
):
|
464 |
-
|
465 |
-
if not self.initialized:
|
466 |
-
self.initialize()
|
467 |
-
objects, output_dir = self._fix_object_args(objects, output_dir)
|
468 |
-
fixed_args = self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
|
469 |
-
libraries, library_dirs, runtime_library_dirs = fixed_args
|
470 |
-
|
471 |
-
if runtime_library_dirs:
|
472 |
-
self.warn(
|
473 |
-
"I don't know what to do with 'runtime_library_dirs': "
|
474 |
-
+ str(runtime_library_dirs)
|
475 |
-
)
|
476 |
-
|
477 |
-
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries)
|
478 |
-
if output_dir is not None:
|
479 |
-
output_filename = os.path.join(output_dir, output_filename)
|
480 |
-
|
481 |
-
if self._need_link(objects, output_filename):
|
482 |
-
ldflags = self._ldflags[target_desc, debug]
|
483 |
-
|
484 |
-
export_opts = ["/EXPORT:" + sym for sym in (export_symbols or [])]
|
485 |
-
|
486 |
-
ld_args = (
|
487 |
-
ldflags + lib_opts + export_opts + objects + ['/OUT:' + output_filename]
|
488 |
-
)
|
489 |
-
|
490 |
-
# The MSVC linker generates .lib and .exp files, which cannot be
|
491 |
-
# suppressed by any linker switches. The .lib files may even be
|
492 |
-
# needed! Make sure they are generated in the temporary build
|
493 |
-
# directory. Since they have different names for debug and release
|
494 |
-
# builds, they can go into the same directory.
|
495 |
-
build_temp = os.path.dirname(objects[0])
|
496 |
-
if export_symbols is not None:
|
497 |
-
(dll_name, dll_ext) = os.path.splitext(
|
498 |
-
os.path.basename(output_filename)
|
499 |
-
)
|
500 |
-
implib_file = os.path.join(build_temp, self.library_filename(dll_name))
|
501 |
-
ld_args.append('/IMPLIB:' + implib_file)
|
502 |
-
|
503 |
-
if extra_preargs:
|
504 |
-
ld_args[:0] = extra_preargs
|
505 |
-
if extra_postargs:
|
506 |
-
ld_args.extend(extra_postargs)
|
507 |
-
|
508 |
-
output_dir = os.path.dirname(os.path.abspath(output_filename))
|
509 |
-
self.mkpath(output_dir)
|
510 |
-
try:
|
511 |
-
log.debug('Executing "%s" %s', self.linker, ' '.join(ld_args))
|
512 |
-
self.spawn([self.linker] + ld_args)
|
513 |
-
except DistutilsExecError as msg:
|
514 |
-
raise LinkError(msg)
|
515 |
-
else:
|
516 |
-
log.debug("skipping %s (up-to-date)", output_filename)
|
517 |
-
|
518 |
-
def spawn(self, cmd):
|
519 |
-
env = dict(os.environ, PATH=self._paths)
|
520 |
-
with self._fallback_spawn(cmd, env) as fallback:
|
521 |
-
return super().spawn(cmd, env=env)
|
522 |
-
return fallback.value
|
523 |
-
|
524 |
-
@contextlib.contextmanager
|
525 |
-
def _fallback_spawn(self, cmd, env):
|
526 |
-
"""
|
527 |
-
Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
|
528 |
-
so the 'env' kwarg causes a TypeError. Detect this condition and
|
529 |
-
restore the legacy, unsafe behavior.
|
530 |
-
"""
|
531 |
-
bag = type('Bag', (), {})()
|
532 |
-
try:
|
533 |
-
yield bag
|
534 |
-
except TypeError as exc:
|
535 |
-
if "unexpected keyword argument 'env'" not in str(exc):
|
536 |
-
raise
|
537 |
-
else:
|
538 |
-
return
|
539 |
-
warnings.warn("Fallback spawn triggered. Please update distutils monkeypatch.")
|
540 |
-
with mock.patch.dict('os.environ', env):
|
541 |
-
bag.value = super().spawn(cmd)
|
542 |
-
|
543 |
-
# -- Miscellaneous methods -----------------------------------------
|
544 |
-
# These are all used by the 'gen_lib_options() function, in
|
545 |
-
# ccompiler.py.
|
546 |
-
|
547 |
-
def library_dir_option(self, dir):
|
548 |
-
return "/LIBPATH:" + dir
|
549 |
-
|
550 |
-
def runtime_library_dir_option(self, dir):
|
551 |
-
raise DistutilsPlatformError(
|
552 |
-
"don't know how to set runtime library search path for MSVC"
|
553 |
-
)
|
554 |
-
|
555 |
-
def library_option(self, lib):
|
556 |
-
return self.library_filename(lib)
|
557 |
-
|
558 |
-
def find_library_file(self, dirs, lib, debug=0):
|
559 |
-
# Prefer a debugging library if found (and requested), but deal
|
560 |
-
# with it if we don't have one.
|
561 |
-
if debug:
|
562 |
-
try_names = [lib + "_d", lib]
|
563 |
-
else:
|
564 |
-
try_names = [lib]
|
565 |
-
for dir in dirs:
|
566 |
-
for name in try_names:
|
567 |
-
libfile = os.path.join(dir, self.library_filename(name))
|
568 |
-
if os.path.isfile(libfile):
|
569 |
-
return libfile
|
570 |
-
else:
|
571 |
-
# Oops, didn't find it in *any* of 'dirs'
|
572 |
-
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Billyosoro/ESRGAN/realesrgan/archs/discriminator_arch.py
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
from basicsr.utils.registry import ARCH_REGISTRY
|
2 |
-
from torch import nn as nn
|
3 |
-
from torch.nn import functional as F
|
4 |
-
from torch.nn.utils import spectral_norm
|
5 |
-
|
6 |
-
|
7 |
-
@ARCH_REGISTRY.register()
|
8 |
-
class UNetDiscriminatorSN(nn.Module):
|
9 |
-
"""Defines a U-Net discriminator with spectral normalization (SN)
|
10 |
-
|
11 |
-
It is used in Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data.
|
12 |
-
|
13 |
-
Arg:
|
14 |
-
num_in_ch (int): Channel number of inputs. Default: 3.
|
15 |
-
num_feat (int): Channel number of base intermediate features. Default: 64.
|
16 |
-
skip_connection (bool): Whether to use skip connections between U-Net. Default: True.
|
17 |
-
"""
|
18 |
-
|
19 |
-
def __init__(self, num_in_ch, num_feat=64, skip_connection=True):
|
20 |
-
super(UNetDiscriminatorSN, self).__init__()
|
21 |
-
self.skip_connection = skip_connection
|
22 |
-
norm = spectral_norm
|
23 |
-
# the first convolution
|
24 |
-
self.conv0 = nn.Conv2d(num_in_ch, num_feat, kernel_size=3, stride=1, padding=1)
|
25 |
-
# downsample
|
26 |
-
self.conv1 = norm(nn.Conv2d(num_feat, num_feat * 2, 4, 2, 1, bias=False))
|
27 |
-
self.conv2 = norm(nn.Conv2d(num_feat * 2, num_feat * 4, 4, 2, 1, bias=False))
|
28 |
-
self.conv3 = norm(nn.Conv2d(num_feat * 4, num_feat * 8, 4, 2, 1, bias=False))
|
29 |
-
# upsample
|
30 |
-
self.conv4 = norm(nn.Conv2d(num_feat * 8, num_feat * 4, 3, 1, 1, bias=False))
|
31 |
-
self.conv5 = norm(nn.Conv2d(num_feat * 4, num_feat * 2, 3, 1, 1, bias=False))
|
32 |
-
self.conv6 = norm(nn.Conv2d(num_feat * 2, num_feat, 3, 1, 1, bias=False))
|
33 |
-
# extra convolutions
|
34 |
-
self.conv7 = norm(nn.Conv2d(num_feat, num_feat, 3, 1, 1, bias=False))
|
35 |
-
self.conv8 = norm(nn.Conv2d(num_feat, num_feat, 3, 1, 1, bias=False))
|
36 |
-
self.conv9 = nn.Conv2d(num_feat, 1, 3, 1, 1)
|
37 |
-
|
38 |
-
def forward(self, x):
|
39 |
-
# downsample
|
40 |
-
x0 = F.leaky_relu(self.conv0(x), negative_slope=0.2, inplace=True)
|
41 |
-
x1 = F.leaky_relu(self.conv1(x0), negative_slope=0.2, inplace=True)
|
42 |
-
x2 = F.leaky_relu(self.conv2(x1), negative_slope=0.2, inplace=True)
|
43 |
-
x3 = F.leaky_relu(self.conv3(x2), negative_slope=0.2, inplace=True)
|
44 |
-
|
45 |
-
# upsample
|
46 |
-
x3 = F.interpolate(x3, scale_factor=2, mode='bilinear', align_corners=False)
|
47 |
-
x4 = F.leaky_relu(self.conv4(x3), negative_slope=0.2, inplace=True)
|
48 |
-
|
49 |
-
if self.skip_connection:
|
50 |
-
x4 = x4 + x2
|
51 |
-
x4 = F.interpolate(x4, scale_factor=2, mode='bilinear', align_corners=False)
|
52 |
-
x5 = F.leaky_relu(self.conv5(x4), negative_slope=0.2, inplace=True)
|
53 |
-
|
54 |
-
if self.skip_connection:
|
55 |
-
x5 = x5 + x1
|
56 |
-
x5 = F.interpolate(x5, scale_factor=2, mode='bilinear', align_corners=False)
|
57 |
-
x6 = F.leaky_relu(self.conv6(x5), negative_slope=0.2, inplace=True)
|
58 |
-
|
59 |
-
if self.skip_connection:
|
60 |
-
x6 = x6 + x0
|
61 |
-
|
62 |
-
# extra convolutions
|
63 |
-
out = F.leaky_relu(self.conv7(x6), negative_slope=0.2, inplace=True)
|
64 |
-
out = F.leaky_relu(self.conv8(out), negative_slope=0.2, inplace=True)
|
65 |
-
out = self.conv9(out)
|
66 |
-
|
67 |
-
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/BramVanroy/mai-simplification-nl-2023-demo/utils.py
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
from typing import List, Tuple
|
2 |
-
|
3 |
-
import streamlit as st
|
4 |
-
import torch
|
5 |
-
from optimum.bettertransformer import BetterTransformer
|
6 |
-
from torch import nn, qint8
|
7 |
-
from torch.quantization import quantize_dynamic
|
8 |
-
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
9 |
-
|
10 |
-
|
11 |
-
@st.cache_resource(show_spinner=False)
|
12 |
-
def get_resources(quantize: bool = True, no_cuda: bool = False) -> Tuple[T5ForConditionalGeneration, T5Tokenizer]:
|
13 |
-
"""Load a T5 model and its (slow) tokenizer"""
|
14 |
-
tokenizer = T5Tokenizer.from_pretrained("BramVanroy/ul2-base-dutch-simplification-mai-2023", use_fast=False)
|
15 |
-
model = T5ForConditionalGeneration.from_pretrained("BramVanroy/ul2-base-dutch-simplification-mai-2023")
|
16 |
-
|
17 |
-
model = BetterTransformer.transform(model, keep_original_model=False)
|
18 |
-
model.resize_token_embeddings(len(tokenizer))
|
19 |
-
|
20 |
-
if torch.cuda.is_available() and not no_cuda:
|
21 |
-
model = model.to("cuda")
|
22 |
-
elif quantize: # Quantization not supported on CUDA
|
23 |
-
model = quantize_dynamic(model, {nn.Linear, nn.Dropout, nn.LayerNorm}, dtype=qint8)
|
24 |
-
|
25 |
-
model.eval()
|
26 |
-
|
27 |
-
return model, tokenizer
|
28 |
-
|
29 |
-
|
30 |
-
def batchify(iterable, batch_size=16):
|
31 |
-
"""Turn an iterable in a batch generator
|
32 |
-
:param iterable: iterable to batchify
|
33 |
-
:param batch_size: batch size
|
34 |
-
"""
|
35 |
-
num_items = len(iterable)
|
36 |
-
for idx in range(0, num_items, batch_size):
|
37 |
-
yield iterable[idx : min(idx + batch_size, num_items)]
|
38 |
-
|
39 |
-
|
40 |
-
def simplify(
|
41 |
-
texts: List[str], model: T5ForConditionalGeneration, tokenizer: T5Tokenizer, batch_size: int = 16
|
42 |
-
) -> List[str]:
|
43 |
-
"""Simplify a given set of texts with a given model and tokenizer. Yields results in batches of 'batch_size'
|
44 |
-
:param texts: texts to simplify
|
45 |
-
:param model: model to use for simplification
|
46 |
-
:param tokenizer: tokenizer to use for simplification
|
47 |
-
:param batch_size: batch size to yield results in
|
48 |
-
"""
|
49 |
-
for batch_texts in batchify(texts, batch_size=batch_size):
|
50 |
-
nlg_batch_texts = ["[NLG] " + text for text in batch_texts]
|
51 |
-
encoded = tokenizer(nlg_batch_texts, return_tensors="pt", padding=True)
|
52 |
-
encoded = {k: v.to(model.device) for k, v in encoded.items()}
|
53 |
-
gen_kwargs = {
|
54 |
-
"max_new_tokens": 128,
|
55 |
-
"num_beams": 3,
|
56 |
-
}
|
57 |
-
|
58 |
-
with torch.no_grad():
|
59 |
-
encoded = {k: v.to(model.device) for k, v in encoded.items()}
|
60 |
-
generated = model.generate(**encoded, **gen_kwargs).cpu()
|
61 |
-
|
62 |
-
yield batch_texts, tokenizer.batch_decode(generated, skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/LIVE/pybind11/tests/test_embed/catch.cpp
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
// The Catch implementation is compiled here. This is a standalone
|
2 |
-
// translation unit to avoid recompiling it for every test change.
|
3 |
-
|
4 |
-
#include <pybind11/embed.h>
|
5 |
-
|
6 |
-
#ifdef _MSC_VER
|
7 |
-
// Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch
|
8 |
-
// 2.0.1; this should be fixed in the next catch release after 2.0.1).
|
9 |
-
# pragma warning(disable: 4996)
|
10 |
-
#endif
|
11 |
-
|
12 |
-
#define CATCH_CONFIG_RUNNER
|
13 |
-
#include <catch.hpp>
|
14 |
-
|
15 |
-
namespace py = pybind11;
|
16 |
-
|
17 |
-
int main(int argc, char *argv[]) {
|
18 |
-
py::scoped_interpreter guard{};
|
19 |
-
auto result = Catch::Session().run(argc, argv);
|
20 |
-
|
21 |
-
return result < 0xff ? result : 0xff;
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/LIVE/thrust/thrust/merge.h
DELETED
@@ -1,680 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* Copyright 2008-2013 NVIDIA Corporation
|
3 |
-
*
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
* you may not use this file except in compliance with the License.
|
6 |
-
* You may obtain a copy of the License at
|
7 |
-
*
|
8 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
*
|
10 |
-
* Unless required by applicable law or agreed to in writing, software
|
11 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
* See the License for the specific language governing permissions and
|
14 |
-
* limitations under the License.
|
15 |
-
*/
|
16 |
-
|
17 |
-
/*! \file merge.h
|
18 |
-
* \brief Merging sorted ranges
|
19 |
-
*/
|
20 |
-
|
21 |
-
#pragma once
|
22 |
-
|
23 |
-
#include <thrust/detail/config.h>
|
24 |
-
#include <thrust/detail/execution_policy.h>
|
25 |
-
#include <thrust/pair.h>
|
26 |
-
|
27 |
-
namespace thrust
|
28 |
-
{
|
29 |
-
|
30 |
-
|
31 |
-
/*! \addtogroup merging Merging
|
32 |
-
* \ingroup algorithms
|
33 |
-
* \{
|
34 |
-
*/
|
35 |
-
|
36 |
-
|
37 |
-
/*! \p merge combines two sorted ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt>
|
38 |
-
* into a single sorted range. That is, it copies from <tt>[first1, last1)</tt> and
|
39 |
-
* <tt>[first2, last2)</tt> into <tt>[result, result + (last1 - first1) + (last2 - first2))</tt>
|
40 |
-
* such that the resulting range is in ascending order. \p merge is stable, meaning both that the
|
41 |
-
* relative order of elements within each input range is preserved, and that for equivalent elements
|
42 |
-
* in both input ranges the element from the first range precedes the element from the second. The
|
43 |
-
* return value is <tt>result + (last1 - first1) + (last2 - first2)</tt>.
|
44 |
-
*
|
45 |
-
* This version of \p merge compares elements using \c operator<.
|
46 |
-
*
|
47 |
-
* The algorithm's execution is parallelized as determined by \p exec.
|
48 |
-
*
|
49 |
-
* \param exec The execution policy to use for parallelization.
|
50 |
-
* \param first1 The beginning of the first input range.
|
51 |
-
* \param last1 The end of the first input range.
|
52 |
-
* \param first2 The beginning of the second input range.
|
53 |
-
* \param last2 The end of the second input range.
|
54 |
-
* \param result The beginning of the merged output.
|
55 |
-
* \return The end of the output range.
|
56 |
-
*
|
57 |
-
* \tparam DerivedPolicy The name of the derived execution policy.
|
58 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
59 |
-
* \p InputIterator1 and \p InputIterator2 have the same \c value_type,
|
60 |
-
* \p InputIterator1's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
61 |
-
* the ordering on \p InputIterator1's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
62 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
63 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
64 |
-
* \p InputIterator2 and \p InputIterator1 have the same \c value_type,
|
65 |
-
* \p InputIterator2's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
66 |
-
* the ordering on \p InputIterator2's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
67 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
68 |
-
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
69 |
-
*
|
70 |
-
* \pre The ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt> shall be sorted with respect to <tt>operator<</tt>.
|
71 |
-
* \pre The resulting range shall not overlap with either input range.
|
72 |
-
*
|
73 |
-
* The following code snippet demonstrates how to use
|
74 |
-
* \p merge to compute the merger of two sorted sets of integers using the \p thrust::host execution policy for parallelization:
|
75 |
-
*
|
76 |
-
* \code
|
77 |
-
* #include <thrust/merge.h>
|
78 |
-
* #include <thrust/execution_policy.h>
|
79 |
-
* ...
|
80 |
-
* int A1[6] = {1, 3, 5, 7, 9, 11};
|
81 |
-
* int A2[7] = {1, 1, 2, 3, 5, 8, 13};
|
82 |
-
*
|
83 |
-
* int result[13];
|
84 |
-
*
|
85 |
-
* int *result_end =
|
86 |
-
* thrust::merge(thrust::host,
|
87 |
-
* A1, A1 + 6,
|
88 |
-
* A2, A2 + 7,
|
89 |
-
* result);
|
90 |
-
* // result = {1, 1, 1, 2, 3, 3, 5, 5, 7, 8, 9, 11, 13}
|
91 |
-
* \endcode
|
92 |
-
*
|
93 |
-
* \see http://www.sgi.com/tech/stl/merge.html
|
94 |
-
* \see \p set_union
|
95 |
-
* \see \p sort
|
96 |
-
* \see \p is_sorted
|
97 |
-
*/
|
98 |
-
template<typename DerivedPolicy,
|
99 |
-
typename InputIterator1,
|
100 |
-
typename InputIterator2,
|
101 |
-
typename OutputIterator>
|
102 |
-
__host__ __device__
|
103 |
-
OutputIterator merge(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
104 |
-
InputIterator1 first1,
|
105 |
-
InputIterator1 last1,
|
106 |
-
InputIterator2 first2,
|
107 |
-
InputIterator2 last2,
|
108 |
-
OutputIterator result);
|
109 |
-
|
110 |
-
|
111 |
-
/*! \p merge combines two sorted ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt>
|
112 |
-
* into a single sorted range. That is, it copies from <tt>[first1, last1)</tt> and
|
113 |
-
* <tt>[first2, last2)</tt> into <tt>[result, result + (last1 - first1) + (last2 - first2))</tt>
|
114 |
-
* such that the resulting range is in ascending order. \p merge is stable, meaning both that the
|
115 |
-
* relative order of elements within each input range is preserved, and that for equivalent elements
|
116 |
-
* in both input ranges the element from the first range precedes the element from the second. The
|
117 |
-
* return value is <tt>result + (last1 - first1) + (last2 - first2)</tt>.
|
118 |
-
*
|
119 |
-
* This version of \p merge compares elements using \c operator<.
|
120 |
-
*
|
121 |
-
* \param first1 The beginning of the first input range.
|
122 |
-
* \param last1 The end of the first input range.
|
123 |
-
* \param first2 The beginning of the second input range.
|
124 |
-
* \param last2 The end of the second input range.
|
125 |
-
* \param result The beginning of the merged output.
|
126 |
-
* \return The end of the output range.
|
127 |
-
*
|
128 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
129 |
-
* \p InputIterator1 and \p InputIterator2 have the same \c value_type,
|
130 |
-
* \p InputIterator1's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
131 |
-
* the ordering on \p InputIterator1's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
132 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
133 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
134 |
-
* \p InputIterator2 and \p InputIterator1 have the same \c value_type,
|
135 |
-
* \p InputIterator2's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
136 |
-
* the ordering on \p InputIterator2's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
137 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
138 |
-
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
139 |
-
*
|
140 |
-
* \pre The ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt> shall be sorted with respect to <tt>operator<</tt>.
|
141 |
-
* \pre The resulting range shall not overlap with either input range.
|
142 |
-
*
|
143 |
-
* The following code snippet demonstrates how to use
|
144 |
-
* \p merge to compute the merger of two sorted sets of integers.
|
145 |
-
*
|
146 |
-
* \code
|
147 |
-
* #include <thrust/merge.h>
|
148 |
-
* ...
|
149 |
-
* int A1[6] = {1, 3, 5, 7, 9, 11};
|
150 |
-
* int A2[7] = {1, 1, 2, 3, 5, 8, 13};
|
151 |
-
*
|
152 |
-
* int result[13];
|
153 |
-
*
|
154 |
-
* int *result_end = thrust::merge(A1, A1 + 6, A2, A2 + 7, result);
|
155 |
-
* // result = {1, 1, 1, 2, 3, 3, 5, 5, 7, 8, 9, 11, 13}
|
156 |
-
* \endcode
|
157 |
-
*
|
158 |
-
* \see http://www.sgi.com/tech/stl/merge.html
|
159 |
-
* \see \p set_union
|
160 |
-
* \see \p sort
|
161 |
-
* \see \p is_sorted
|
162 |
-
*/
|
163 |
-
template<typename InputIterator1,
|
164 |
-
typename InputIterator2,
|
165 |
-
typename OutputIterator>
|
166 |
-
OutputIterator merge(InputIterator1 first1,
|
167 |
-
InputIterator1 last1,
|
168 |
-
InputIterator2 first2,
|
169 |
-
InputIterator2 last2,
|
170 |
-
OutputIterator result);
|
171 |
-
|
172 |
-
|
173 |
-
/*! \p merge combines two sorted ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt>
|
174 |
-
* into a single sorted range. That is, it copies from <tt>[first1, last1)</tt> and
|
175 |
-
* <tt>[first2, last2)</tt> into <tt>[result, result + (last1 - first1) + (last2 - first2))</tt>
|
176 |
-
* such that the resulting range is in ascending order. \p merge is stable, meaning both that the
|
177 |
-
* relative order of elements within each input range is preserved, and that for equivalent elements
|
178 |
-
* in both input ranges the element from the first range precedes the element from the second. The
|
179 |
-
* return value is <tt>result + (last1 - first1) + (last2 - first2)</tt>.
|
180 |
-
*
|
181 |
-
* This version of \p merge compares elements using a function object \p comp.
|
182 |
-
*
|
183 |
-
* The algorithm's execution is parallelized as determined by \p exec.
|
184 |
-
*
|
185 |
-
* \param exec The execution policy to use for parallelization.
|
186 |
-
* \param first1 The beginning of the first input range.
|
187 |
-
* \param last1 The end of the first input range.
|
188 |
-
* \param first2 The beginning of the second input range.
|
189 |
-
* \param last2 The end of the second input range.
|
190 |
-
* \param result The beginning of the merged output.
|
191 |
-
* \param comp Comparison operator.
|
192 |
-
* \return The end of the output range.
|
193 |
-
*
|
194 |
-
* \tparam DerivedPolicy The name of the derived execution policy.
|
195 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
196 |
-
* \p InputIterator1's \c value_type is convertable to \p StrictWeakCompare's \c first_argument_type.
|
197 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
198 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
199 |
-
* \p InputIterator2's \c value_type is convertable to \p StrictWeakCompare's \c second_argument_type.
|
200 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
201 |
-
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
202 |
-
* \tparam StrictWeakCompare is a model of <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">Strict Weak Ordering</a>.
|
203 |
-
*
|
204 |
-
* \pre The ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt> shall be sorted with respect to \p comp.
|
205 |
-
* \pre The resulting range shall not overlap with either input range.
|
206 |
-
*
|
207 |
-
* The following code snippet demonstrates how to use
|
208 |
-
* \p merge to compute the merger of two sets of integers sorted in
|
209 |
-
* descending order using the \p thrust::host execution policy for parallelization:
|
210 |
-
*
|
211 |
-
* \code
|
212 |
-
* #include <thrust/merge.h>
|
213 |
-
* #include <thrust/functional.h>
|
214 |
-
* #include <thrust/execution_policy.h>
|
215 |
-
* ...
|
216 |
-
* int A1[6] = {11, 9, 7, 5, 3, 1};
|
217 |
-
* int A2[7] = {13, 8, 5, 3, 2, 1, 1};
|
218 |
-
*
|
219 |
-
* int result[13];
|
220 |
-
*
|
221 |
-
* int *result_end = thrust::merge(thrust::host,
|
222 |
-
* A1, A1 + 6,
|
223 |
-
* A2, A2 + 7,
|
224 |
-
* result,
|
225 |
-
* thrust::greater<int>());
|
226 |
-
* // result = {13, 11, 9, 8, 7, 5, 5, 3, 3, 2, 1, 1, 1}
|
227 |
-
* \endcode
|
228 |
-
*
|
229 |
-
* \see http://www.sgi.com/tech/stl/merge.html
|
230 |
-
* \see \p sort
|
231 |
-
* \see \p is_sorted
|
232 |
-
*/
|
233 |
-
template<typename DerivedPolicy,
|
234 |
-
typename InputIterator1,
|
235 |
-
typename InputIterator2,
|
236 |
-
typename OutputIterator,
|
237 |
-
typename StrictWeakCompare>
|
238 |
-
__host__ __device__
|
239 |
-
OutputIterator merge(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
240 |
-
InputIterator1 first1,
|
241 |
-
InputIterator1 last1,
|
242 |
-
InputIterator2 first2,
|
243 |
-
InputIterator2 last2,
|
244 |
-
OutputIterator result,
|
245 |
-
StrictWeakCompare comp);
|
246 |
-
|
247 |
-
|
248 |
-
/*! \p merge combines two sorted ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt>
|
249 |
-
* into a single sorted range. That is, it copies from <tt>[first1, last1)</tt> and
|
250 |
-
* <tt>[first2, last2)</tt> into <tt>[result, result + (last1 - first1) + (last2 - first2))</tt>
|
251 |
-
* such that the resulting range is in ascending order. \p merge is stable, meaning both that the
|
252 |
-
* relative order of elements within each input range is preserved, and that for equivalent elements
|
253 |
-
* in both input ranges the element from the first range precedes the element from the second. The
|
254 |
-
* return value is <tt>result + (last1 - first1) + (last2 - first2)</tt>.
|
255 |
-
*
|
256 |
-
* This version of \p merge compares elements using a function object \p comp.
|
257 |
-
*
|
258 |
-
* \param first1 The beginning of the first input range.
|
259 |
-
* \param last1 The end of the first input range.
|
260 |
-
* \param first2 The beginning of the second input range.
|
261 |
-
* \param last2 The end of the second input range.
|
262 |
-
* \param result The beginning of the merged output.
|
263 |
-
* \param comp Comparison operator.
|
264 |
-
* \return The end of the output range.
|
265 |
-
*
|
266 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
267 |
-
* \p InputIterator1's \c value_type is convertable to \p StrictWeakCompare's \c first_argument_type.
|
268 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
269 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
270 |
-
* \p InputIterator2's \c value_type is convertable to \p StrictWeakCompare's \c second_argument_type.
|
271 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
272 |
-
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
273 |
-
* \tparam StrictWeakCompare is a model of <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">Strict Weak Ordering</a>.
|
274 |
-
*
|
275 |
-
* \pre The ranges <tt>[first1, last1)</tt> and <tt>[first2, last2)</tt> shall be sorted with respect to \p comp.
|
276 |
-
* \pre The resulting range shall not overlap with either input range.
|
277 |
-
*
|
278 |
-
* The following code snippet demonstrates how to use
|
279 |
-
* \p merge to compute the merger of two sets of integers sorted in
|
280 |
-
* descending order.
|
281 |
-
*
|
282 |
-
* \code
|
283 |
-
* #include <thrust/merge.h>
|
284 |
-
* #include <thrust/functional.h>
|
285 |
-
* ...
|
286 |
-
* int A1[6] = {11, 9, 7, 5, 3, 1};
|
287 |
-
* int A2[7] = {13, 8, 5, 3, 2, 1, 1};
|
288 |
-
*
|
289 |
-
* int result[13];
|
290 |
-
*
|
291 |
-
* int *result_end = thrust::merge(A1, A1 + 6, A2, A2 + 7, result, thrust::greater<int>());
|
292 |
-
* // result = {13, 11, 9, 8, 7, 5, 5, 3, 3, 2, 1, 1, 1}
|
293 |
-
* \endcode
|
294 |
-
*
|
295 |
-
* \see http://www.sgi.com/tech/stl/merge.html
|
296 |
-
* \see \p sort
|
297 |
-
* \see \p is_sorted
|
298 |
-
*/
|
299 |
-
template<typename InputIterator1,
|
300 |
-
typename InputIterator2,
|
301 |
-
typename OutputIterator,
|
302 |
-
typename StrictWeakCompare>
|
303 |
-
OutputIterator merge(InputIterator1 first1,
|
304 |
-
InputIterator1 last1,
|
305 |
-
InputIterator2 first2,
|
306 |
-
InputIterator2 last2,
|
307 |
-
OutputIterator result,
|
308 |
-
StrictWeakCompare comp);
|
309 |
-
|
310 |
-
|
311 |
-
/*! \p merge_by_key performs a key-value merge. That is, \p merge_by_key copies elements from
|
312 |
-
* <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> into a single range,
|
313 |
-
* <tt>[keys_result, keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
314 |
-
* the resulting range is in ascending key order.
|
315 |
-
*
|
316 |
-
* At the same time, \p merge_by_key copies elements from the two associated ranges <tt>[values_first1 + (keys_last1 - keys_first1))</tt>
|
317 |
-
* and <tt>[values_first2 + (keys_last2 - keys_first2))</tt> into a single range,
|
318 |
-
* <tt>[values_result, values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
319 |
-
* the resulting range is in ascending order implied by each input element's associated key.
|
320 |
-
*
|
321 |
-
* \p merge_by_key is stable, meaning both that the relative order of elements within each input range is
|
322 |
-
* preserved, and that for equivalent elements in all input key ranges the element from the first range
|
323 |
-
* precedes the element from the second.
|
324 |
-
*
|
325 |
-
* The return value is is <tt>(keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>
|
326 |
-
* and <tt>(values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>.
|
327 |
-
*
|
328 |
-
* The algorithm's execution is parallelized as determined by \p exec.
|
329 |
-
*
|
330 |
-
* \param exec The execution policy to use for parallelization.
|
331 |
-
* \param keys_first1 The beginning of the first input range of keys.
|
332 |
-
* \param keys_last1 The end of the first input range of keys.
|
333 |
-
* \param keys_first2 The beginning of the second input range of keys.
|
334 |
-
* \param keys_last2 The end of the second input range of keys.
|
335 |
-
* \param values_first1 The beginning of the first input range of values.
|
336 |
-
* \param values_first2 The beginning of the first input range of values.
|
337 |
-
* \param keys_result The beginning of the merged output range of keys.
|
338 |
-
* \param values_result The beginning of the merged output range of values.
|
339 |
-
* \return A \p pair \c p such that <tt>p.first</tt> is the end of the output range of keys,
|
340 |
-
* and such that <tt>p.second</tt> is the end of the output range of values.
|
341 |
-
*
|
342 |
-
* \tparam DerivedPolicy The name of the derived execution policy.
|
343 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
344 |
-
* \p InputIterator1 and \p InputIterator2 have the same \c value_type,
|
345 |
-
* \p InputIterator1's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
346 |
-
* the ordering on \p InputIterator1's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
347 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
348 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
349 |
-
* \p InputIterator2 and \p InputIterator1 have the same \c value_type,
|
350 |
-
* \p InputIterator2's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
351 |
-
* the ordering on \p InputIterator2's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
352 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
353 |
-
* \tparam InputIterator3 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
354 |
-
* and \p InputIterator3's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
355 |
-
* \tparam InputIterator4 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
356 |
-
* and \p InputIterator4's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
357 |
-
* \tparam OutputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
358 |
-
* \tparam OutputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
359 |
-
*
|
360 |
-
* \pre The ranges <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> shall be sorted with respect to <tt>operator<</tt>.
|
361 |
-
* \pre The resulting ranges shall not overlap with any input range.
|
362 |
-
*
|
363 |
-
* The following code snippet demonstrates how to use
|
364 |
-
* \p merge_by_key to compute the merger of two sets of integers sorted in
|
365 |
-
* ascending order using the \p thrust::host execution policy for parallelization:
|
366 |
-
*
|
367 |
-
* \code
|
368 |
-
* #include <thrust/merge.h>
|
369 |
-
* #include <thrust/functional.h>
|
370 |
-
* #include <thrust/execution_policy.h>
|
371 |
-
* ...
|
372 |
-
* int A_keys[6] = {1, 3, 5, 7, 9, 11};
|
373 |
-
* int A_vals[6] = {0, 0, 0, 0, 0, 0};
|
374 |
-
*
|
375 |
-
* int B_keys[7] = {1, 1, 2, 3, 5, 8, 13};
|
376 |
-
* int B_vals[7] = {1, 1, 1, 1, 1, 1, 1};
|
377 |
-
*
|
378 |
-
* int keys_result[13];
|
379 |
-
* int vals_result[13];
|
380 |
-
*
|
381 |
-
* thrust::pair<int*,int*> end =
|
382 |
-
* thrust::merge_by_key(thrust::host,
|
383 |
-
* A_keys, A_keys + 6,
|
384 |
-
* B_keys, B_keys + 7,
|
385 |
-
* A_vals, B_vals,
|
386 |
-
* keys_result, vals_result);
|
387 |
-
*
|
388 |
-
* // keys_result = {1, 1, 1, 2, 3, 3, 5, 5, 7, 8, 9, 11, 13}
|
389 |
-
* // vals_result = {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1}
|
390 |
-
* \endcode
|
391 |
-
*
|
392 |
-
* \see merge
|
393 |
-
* \see \p sort_by_key
|
394 |
-
* \see \p is_sorted
|
395 |
-
*/
|
396 |
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename InputIterator3, typename InputIterator4, typename OutputIterator1, typename OutputIterator2>
|
397 |
-
__host__ __device__
|
398 |
-
thrust::pair<OutputIterator1,OutputIterator2>
|
399 |
-
merge_by_key(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
400 |
-
InputIterator1 keys_first1, InputIterator1 keys_last1,
|
401 |
-
InputIterator2 keys_first2, InputIterator2 keys_last2,
|
402 |
-
InputIterator3 values_first1, InputIterator4 values_first2,
|
403 |
-
OutputIterator1 keys_result,
|
404 |
-
OutputIterator2 values_result);
|
405 |
-
|
406 |
-
|
407 |
-
/*! \p merge_by_key performs a key-value merge. That is, \p merge_by_key copies elements from
|
408 |
-
* <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> into a single range,
|
409 |
-
* <tt>[keys_result, keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
410 |
-
* the resulting range is in ascending key order.
|
411 |
-
*
|
412 |
-
* At the same time, \p merge_by_key copies elements from the two associated ranges <tt>[values_first1 + (keys_last1 - keys_first1))</tt>
|
413 |
-
* and <tt>[values_first2 + (keys_last2 - keys_first2))</tt> into a single range,
|
414 |
-
* <tt>[values_result, values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
415 |
-
* the resulting range is in ascending order implied by each input element's associated key.
|
416 |
-
*
|
417 |
-
* \p merge_by_key is stable, meaning both that the relative order of elements within each input range is
|
418 |
-
* preserved, and that for equivalent elements in all input key ranges the element from the first range
|
419 |
-
* precedes the element from the second.
|
420 |
-
*
|
421 |
-
* The return value is is <tt>(keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>
|
422 |
-
* and <tt>(values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>.
|
423 |
-
*
|
424 |
-
* \param keys_first1 The beginning of the first input range of keys.
|
425 |
-
* \param keys_last1 The end of the first input range of keys.
|
426 |
-
* \param keys_first2 The beginning of the second input range of keys.
|
427 |
-
* \param keys_last2 The end of the second input range of keys.
|
428 |
-
* \param values_first1 The beginning of the first input range of values.
|
429 |
-
* \param values_first2 The beginning of the first input range of values.
|
430 |
-
* \param keys_result The beginning of the merged output range of keys.
|
431 |
-
* \param values_result The beginning of the merged output range of values.
|
432 |
-
* \return A \p pair \c p such that <tt>p.first</tt> is the end of the output range of keys,
|
433 |
-
* and such that <tt>p.second</tt> is the end of the output range of values.
|
434 |
-
*
|
435 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
436 |
-
* \p InputIterator1 and \p InputIterator2 have the same \c value_type,
|
437 |
-
* \p InputIterator1's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
438 |
-
* the ordering on \p InputIterator1's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
439 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
440 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
441 |
-
* \p InputIterator2 and \p InputIterator1 have the same \c value_type,
|
442 |
-
* \p InputIterator2's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a>,
|
443 |
-
* the ordering on \p InputIterator2's \c value_type is a strict weak ordering, as defined in the <a href="http://www.sgi.com/tech/stl/LessThanComparable">LessThan Comparable</a> requirements,
|
444 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator's set of \c value_types.
|
445 |
-
* \tparam InputIterator3 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
446 |
-
* and \p InputIterator3's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
447 |
-
* \tparam InputIterator4 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
448 |
-
* and \p InputIterator4's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
449 |
-
* \tparam OutputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
450 |
-
* \tparam OutputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
451 |
-
*
|
452 |
-
* \pre The ranges <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> shall be sorted with respect to <tt>operator<</tt>.
|
453 |
-
* \pre The resulting ranges shall not overlap with any input range.
|
454 |
-
*
|
455 |
-
* The following code snippet demonstrates how to use
|
456 |
-
* \p merge_by_key to compute the merger of two sets of integers sorted in
|
457 |
-
* ascending order.
|
458 |
-
*
|
459 |
-
* \code
|
460 |
-
* #include <thrust/merge.h>
|
461 |
-
* #include <thrust/functional.h>
|
462 |
-
* ...
|
463 |
-
* int A_keys[6] = {1, 3, 5, 7, 9, 11};
|
464 |
-
* int A_vals[6] = {0, 0, 0, 0, 0, 0};
|
465 |
-
*
|
466 |
-
* int B_keys[7] = {1, 1, 2, 3, 5, 8, 13};
|
467 |
-
* int B_vals[7] = {1, 1, 1, 1, 1, 1, 1};
|
468 |
-
*
|
469 |
-
* int keys_result[13];
|
470 |
-
* int vals_result[13];
|
471 |
-
*
|
472 |
-
* thrust::pair<int*,int*> end = thrust::merge_by_key(A_keys, A_keys + 6, B_keys, B_keys + 7, A_vals, B_vals, keys_result, vals_result);
|
473 |
-
*
|
474 |
-
* // keys_result = {1, 1, 1, 2, 3, 3, 5, 5, 7, 8, 9, 11, 13}
|
475 |
-
* // vals_result = {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1}
|
476 |
-
* \endcode
|
477 |
-
*
|
478 |
-
* \see merge
|
479 |
-
* \see \p sort_by_key
|
480 |
-
* \see \p is_sorted
|
481 |
-
*/
|
482 |
-
template<typename InputIterator1, typename InputIterator2, typename InputIterator3, typename InputIterator4, typename OutputIterator1, typename OutputIterator2>
|
483 |
-
thrust::pair<OutputIterator1,OutputIterator2>
|
484 |
-
merge_by_key(InputIterator1 keys_first1, InputIterator1 keys_last1,
|
485 |
-
InputIterator2 keys_first2, InputIterator2 keys_last2,
|
486 |
-
InputIterator3 values_first1, InputIterator4 values_first2,
|
487 |
-
OutputIterator1 keys_result,
|
488 |
-
OutputIterator2 values_result);
|
489 |
-
|
490 |
-
|
491 |
-
/*! \p merge_by_key performs a key-value merge. That is, \p merge_by_key copies elements from
|
492 |
-
* <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> into a single range,
|
493 |
-
* <tt>[keys_result, keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
494 |
-
* the resulting range is in ascending key order.
|
495 |
-
*
|
496 |
-
* At the same time, \p merge_by_key copies elements from the two associated ranges <tt>[values_first1 + (keys_last1 - keys_first1))</tt>
|
497 |
-
* and <tt>[values_first2 + (keys_last2 - keys_first2))</tt> into a single range,
|
498 |
-
* <tt>[values_result, values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
499 |
-
* the resulting range is in ascending order implied by each input element's associated key.
|
500 |
-
*
|
501 |
-
* \p merge_by_key is stable, meaning both that the relative order of elements within each input range is
|
502 |
-
* preserved, and that for equivalent elements in all input key ranges the element from the first range
|
503 |
-
* precedes the element from the second.
|
504 |
-
*
|
505 |
-
* The return value is is <tt>(keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>
|
506 |
-
* and <tt>(values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>.
|
507 |
-
*
|
508 |
-
* This version of \p merge_by_key compares key elements using a function object \p comp.
|
509 |
-
*
|
510 |
-
* The algorithm's execution is parallelized using \p exec.
|
511 |
-
*
|
512 |
-
* \param exec The execution policy to use for parallelization.
|
513 |
-
* \param keys_first1 The beginning of the first input range of keys.
|
514 |
-
* \param keys_last1 The end of the first input range of keys.
|
515 |
-
* \param keys_first2 The beginning of the second input range of keys.
|
516 |
-
* \param keys_last2 The end of the second input range of keys.
|
517 |
-
* \param values_first1 The beginning of the first input range of values.
|
518 |
-
* \param values_first2 The beginning of the first input range of values.
|
519 |
-
* \param keys_result The beginning of the merged output range of keys.
|
520 |
-
* \param values_result The beginning of the merged output range of values.
|
521 |
-
* \param comp Comparison operator.
|
522 |
-
* \return A \p pair \c p such that <tt>p.first</tt> is the end of the output range of keys,
|
523 |
-
* and such that <tt>p.second</tt> is the end of the output range of values.
|
524 |
-
*
|
525 |
-
* \tparam DerivedPolicy The name of the derived execution policy.
|
526 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
527 |
-
* \p InputIterator1's \c value_type is convertable to \p StrictWeakCompare's \c first_argument_type.
|
528 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator1's set of \c value_types.
|
529 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
530 |
-
* \p InputIterator2's \c value_type is convertable to \p StrictWeakCompare's \c second_argument_type.
|
531 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator1's set of \c value_types.
|
532 |
-
* \tparam InputIterator3 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
533 |
-
* and \p InputIterator3's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
534 |
-
* \tparam InputIterator4 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
535 |
-
* and \p InputIterator4's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
536 |
-
* \tparam OutputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
537 |
-
* \tparam OutputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
538 |
-
* \tparam StrictWeakCompare is a model of <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">Strict Weak Ordering</a>.
|
539 |
-
*
|
540 |
-
* \pre The ranges <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> shall be sorted with respect to \p comp.
|
541 |
-
* \pre The resulting ranges shall not overlap with any input range.
|
542 |
-
*
|
543 |
-
* The following code snippet demonstrates how to use
|
544 |
-
* \p merge_by_key to compute the merger of two sets of integers sorted in
|
545 |
-
* descending order using the \p thrust::host execution policy for parallelization:
|
546 |
-
*
|
547 |
-
* \code
|
548 |
-
* #include <thrust/merge.h>
|
549 |
-
* #include <thrust/functional.h>
|
550 |
-
* #include <thrust/execution_policy.h>
|
551 |
-
* ...
|
552 |
-
* int A_keys[6] = {11, 9, 7, 5, 3, 1};
|
553 |
-
* int A_vals[6] = { 0, 0, 0, 0, 0, 0};
|
554 |
-
*
|
555 |
-
* int B_keys[7] = {13, 8, 5, 3, 2, 1, 1};
|
556 |
-
* int B_vals[7] = { 1, 1, 1, 1, 1, 1, 1};
|
557 |
-
*
|
558 |
-
* int keys_result[13];
|
559 |
-
* int vals_result[13];
|
560 |
-
*
|
561 |
-
* thrust::pair<int*,int*> end =
|
562 |
-
* thrust::merge_by_key(thrust::host,
|
563 |
-
* A_keys, A_keys + 6,
|
564 |
-
* B_keys, B_keys + 7,
|
565 |
-
* A_vals, B_vals,
|
566 |
-
* keys_result, vals_result,
|
567 |
-
* thrust::greater<int>());
|
568 |
-
*
|
569 |
-
* // keys_result = {13, 11, 9, 8, 7, 5, 5, 3, 3, 2, 1, 1, 1}
|
570 |
-
* // vals_result = { 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1}
|
571 |
-
* \endcode
|
572 |
-
*
|
573 |
-
* \see merge
|
574 |
-
* \see \p sort_by_key
|
575 |
-
* \see \p is_sorted
|
576 |
-
*/
|
577 |
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename InputIterator3, typename InputIterator4, typename OutputIterator1, typename OutputIterator2, typename Compare>
|
578 |
-
__host__ __device__
|
579 |
-
thrust::pair<OutputIterator1,OutputIterator2>
|
580 |
-
merge_by_key(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
581 |
-
InputIterator1 keys_first1, InputIterator1 keys_last1,
|
582 |
-
InputIterator2 keys_first2, InputIterator2 keys_last2,
|
583 |
-
InputIterator3 values_first1, InputIterator4 values_first2,
|
584 |
-
OutputIterator1 keys_result,
|
585 |
-
OutputIterator2 values_result,
|
586 |
-
Compare comp);
|
587 |
-
|
588 |
-
|
589 |
-
/*! \p merge_by_key performs a key-value merge. That is, \p merge_by_key copies elements from
|
590 |
-
* <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> into a single range,
|
591 |
-
* <tt>[keys_result, keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
592 |
-
* the resulting range is in ascending key order.
|
593 |
-
*
|
594 |
-
* At the same time, \p merge_by_key copies elements from the two associated ranges <tt>[values_first1 + (keys_last1 - keys_first1))</tt>
|
595 |
-
* and <tt>[values_first2 + (keys_last2 - keys_first2))</tt> into a single range,
|
596 |
-
* <tt>[values_result, values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt> such that
|
597 |
-
* the resulting range is in ascending order implied by each input element's associated key.
|
598 |
-
*
|
599 |
-
* \p merge_by_key is stable, meaning both that the relative order of elements within each input range is
|
600 |
-
* preserved, and that for equivalent elements in all input key ranges the element from the first range
|
601 |
-
* precedes the element from the second.
|
602 |
-
*
|
603 |
-
* The return value is is <tt>(keys_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>
|
604 |
-
* and <tt>(values_result + (keys_last1 - keys_first1) + (keys_last2 - keys_first2))</tt>.
|
605 |
-
*
|
606 |
-
* This version of \p merge_by_key compares key elements using a function object \p comp.
|
607 |
-
*
|
608 |
-
* \param keys_first1 The beginning of the first input range of keys.
|
609 |
-
* \param keys_last1 The end of the first input range of keys.
|
610 |
-
* \param keys_first2 The beginning of the second input range of keys.
|
611 |
-
* \param keys_last2 The end of the second input range of keys.
|
612 |
-
* \param values_first1 The beginning of the first input range of values.
|
613 |
-
* \param values_first2 The beginning of the first input range of values.
|
614 |
-
* \param keys_result The beginning of the merged output range of keys.
|
615 |
-
* \param values_result The beginning of the merged output range of values.
|
616 |
-
* \param comp Comparison operator.
|
617 |
-
* \return A \p pair \c p such that <tt>p.first</tt> is the end of the output range of keys,
|
618 |
-
* and such that <tt>p.second</tt> is the end of the output range of values.
|
619 |
-
*
|
620 |
-
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
621 |
-
* \p InputIterator1's \c value_type is convertable to \p StrictWeakCompare's \c first_argument_type.
|
622 |
-
* and \p InputIterator1's \c value_type is convertable to a type in \p OutputIterator1's set of \c value_types.
|
623 |
-
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
624 |
-
* \p InputIterator2's \c value_type is convertable to \p StrictWeakCompare's \c second_argument_type.
|
625 |
-
* and \p InputIterator2's \c value_type is convertable to a type in \p OutputIterator1's set of \c value_types.
|
626 |
-
* \tparam InputIterator3 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
627 |
-
* and \p InputIterator3's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
628 |
-
* \tparam InputIterator4 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
629 |
-
* and \p InputIterator4's \c value_type is convertible to a type in \p OutputIterator2's set of \c value_types.
|
630 |
-
* \tparam OutputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
631 |
-
* \tparam OutputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
632 |
-
* \tparam StrictWeakCompare is a model of <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">Strict Weak Ordering</a>.
|
633 |
-
*
|
634 |
-
* \pre The ranges <tt>[keys_first1, keys_last1)</tt> and <tt>[keys_first2, keys_last2)</tt> shall be sorted with respect to \p comp.
|
635 |
-
* \pre The resulting ranges shall not overlap with any input range.
|
636 |
-
*
|
637 |
-
* The following code snippet demonstrates how to use
|
638 |
-
* \p merge_by_key to compute the merger of two sets of integers sorted in
|
639 |
-
* descending order.
|
640 |
-
*
|
641 |
-
* \code
|
642 |
-
* #include <thrust/merge.h>
|
643 |
-
* #include <thrust/functional.h>
|
644 |
-
* ...
|
645 |
-
* int A_keys[6] = {11, 9, 7, 5, 3, 1};
|
646 |
-
* int A_vals[6] = { 0, 0, 0, 0, 0, 0};
|
647 |
-
*
|
648 |
-
* int B_keys[7] = {13, 8, 5, 3, 2, 1, 1};
|
649 |
-
* int B_vals[7] = { 1, 1, 1, 1, 1, 1, 1};
|
650 |
-
*
|
651 |
-
* int keys_result[13];
|
652 |
-
* int vals_result[13];
|
653 |
-
*
|
654 |
-
* thrust::pair<int*,int*> end = thrust::merge_by_key(A_keys, A_keys + 6, B_keys, B_keys + 7, A_vals, B_vals, keys_result, vals_result, thrust::greater<int>());
|
655 |
-
*
|
656 |
-
* // keys_result = {13, 11, 9, 8, 7, 5, 5, 3, 3, 2, 1, 1, 1}
|
657 |
-
* // vals_result = { 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1}
|
658 |
-
* \endcode
|
659 |
-
*
|
660 |
-
* \see merge
|
661 |
-
* \see \p sort_by_key
|
662 |
-
* \see \p is_sorted
|
663 |
-
*/
|
664 |
-
template<typename InputIterator1, typename InputIterator2, typename InputIterator3, typename InputIterator4, typename OutputIterator1, typename OutputIterator2, typename StrictWeakCompare>
|
665 |
-
thrust::pair<OutputIterator1,OutputIterator2>
|
666 |
-
merge_by_key(InputIterator1 keys_first1, InputIterator1 keys_last1,
|
667 |
-
InputIterator2 keys_first2, InputIterator2 keys_last2,
|
668 |
-
InputIterator3 values_first1, InputIterator4 values_first2,
|
669 |
-
OutputIterator1 keys_result,
|
670 |
-
OutputIterator2 values_result,
|
671 |
-
StrictWeakCompare comp);
|
672 |
-
|
673 |
-
|
674 |
-
/*! \} // merging
|
675 |
-
*/
|
676 |
-
|
677 |
-
} // end thrust
|
678 |
-
|
679 |
-
#include <thrust/detail/merge.inl>
|
680 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/WALT/docker/Dockerfile
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
ARG PYTORCH="1.9.0"
|
2 |
-
ARG CUDA="11.1"
|
3 |
-
ARG CUDNN="8"
|
4 |
-
|
5 |
-
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
|
6 |
-
|
7 |
-
ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0+PTX"
|
8 |
-
ENV TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
|
9 |
-
ENV CMAKE_PREFIX_PATH="$(dirname $(which conda))/../"
|
10 |
-
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
|
11 |
-
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
|
12 |
-
RUN apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \
|
13 |
-
&& apt-get clean \
|
14 |
-
&& rm -rf /var/lib/apt/lists/*
|
15 |
-
|
16 |
-
# Install MMCV
|
17 |
-
#RUN pip install mmcv-full==1.3.8 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
|
18 |
-
# -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
|
19 |
-
RUN pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
|
20 |
-
# Install MMDetection
|
21 |
-
RUN conda clean --all
|
22 |
-
RUN git clone https://github.com/open-mmlab/mmdetection.git /mmdetection
|
23 |
-
WORKDIR /mmdetection
|
24 |
-
ENV FORCE_CUDA="1"
|
25 |
-
RUN cd /mmdetection && git checkout 7bd39044f35aec4b90dd797b965777541a8678ff
|
26 |
-
RUN pip install -r requirements/build.txt
|
27 |
-
RUN pip install --no-cache-dir -e .
|
28 |
-
RUN apt-get update
|
29 |
-
RUN apt-get install -y vim
|
30 |
-
RUN pip uninstall -y pycocotools
|
31 |
-
RUN pip install mmpycocotools timm scikit-image imagesize
|
32 |
-
|
33 |
-
|
34 |
-
# make sure we don't overwrite some existing directory called "apex"
|
35 |
-
WORKDIR /tmp/unique_for_apex
|
36 |
-
# uninstall Apex if present, twice to make absolutely sure :)
|
37 |
-
RUN pip uninstall -y apex || :
|
38 |
-
RUN pip uninstall -y apex || :
|
39 |
-
# SHA is something the user can touch to force recreation of this Docker layer,
|
40 |
-
# and therefore force cloning of the latest version of Apex
|
41 |
-
RUN SHA=ToUcHMe git clone https://github.com/NVIDIA/apex.git
|
42 |
-
WORKDIR /tmp/unique_for_apex/apex
|
43 |
-
RUN pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .
|
44 |
-
RUN pip install seaborn sklearn imantics gradio
|
45 |
-
WORKDIR /code
|
46 |
-
ENTRYPOINT ["python", "app.py"]
|
47 |
-
|
48 |
-
#RUN git clone https://github.com/NVIDIA/apex
|
49 |
-
#RUN cd apex
|
50 |
-
#RUN pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .
|
51 |
-
#RUN pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/WALT/mmdet/models/dense_heads/anchor_free_head.py
DELETED
@@ -1,340 +0,0 @@
|
|
1 |
-
from abc import abstractmethod
|
2 |
-
|
3 |
-
import torch
|
4 |
-
import torch.nn as nn
|
5 |
-
from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
|
6 |
-
from mmcv.runner import force_fp32
|
7 |
-
|
8 |
-
from mmdet.core import multi_apply
|
9 |
-
from ..builder import HEADS, build_loss
|
10 |
-
from .base_dense_head import BaseDenseHead
|
11 |
-
from .dense_test_mixins import BBoxTestMixin
|
12 |
-
|
13 |
-
|
14 |
-
@HEADS.register_module()
|
15 |
-
class AnchorFreeHead(BaseDenseHead, BBoxTestMixin):
|
16 |
-
"""Anchor-free head (FCOS, Fovea, RepPoints, etc.).
|
17 |
-
|
18 |
-
Args:
|
19 |
-
num_classes (int): Number of categories excluding the background
|
20 |
-
category.
|
21 |
-
in_channels (int): Number of channels in the input feature map.
|
22 |
-
feat_channels (int): Number of hidden channels. Used in child classes.
|
23 |
-
stacked_convs (int): Number of stacking convs of the head.
|
24 |
-
strides (tuple): Downsample factor of each feature map.
|
25 |
-
dcn_on_last_conv (bool): If true, use dcn in the last layer of
|
26 |
-
towers. Default: False.
|
27 |
-
conv_bias (bool | str): If specified as `auto`, it will be decided by
|
28 |
-
the norm_cfg. Bias of conv will be set as True if `norm_cfg` is
|
29 |
-
None, otherwise False. Default: "auto".
|
30 |
-
loss_cls (dict): Config of classification loss.
|
31 |
-
loss_bbox (dict): Config of localization loss.
|
32 |
-
conv_cfg (dict): Config dict for convolution layer. Default: None.
|
33 |
-
norm_cfg (dict): Config dict for normalization layer. Default: None.
|
34 |
-
train_cfg (dict): Training config of anchor head.
|
35 |
-
test_cfg (dict): Testing config of anchor head.
|
36 |
-
""" # noqa: W605
|
37 |
-
|
38 |
-
_version = 1
|
39 |
-
|
40 |
-
def __init__(self,
|
41 |
-
num_classes,
|
42 |
-
in_channels,
|
43 |
-
feat_channels=256,
|
44 |
-
stacked_convs=4,
|
45 |
-
strides=(4, 8, 16, 32, 64),
|
46 |
-
dcn_on_last_conv=False,
|
47 |
-
conv_bias='auto',
|
48 |
-
loss_cls=dict(
|
49 |
-
type='FocalLoss',
|
50 |
-
use_sigmoid=True,
|
51 |
-
gamma=2.0,
|
52 |
-
alpha=0.25,
|
53 |
-
loss_weight=1.0),
|
54 |
-
loss_bbox=dict(type='IoULoss', loss_weight=1.0),
|
55 |
-
conv_cfg=None,
|
56 |
-
norm_cfg=None,
|
57 |
-
train_cfg=None,
|
58 |
-
test_cfg=None):
|
59 |
-
super(AnchorFreeHead, self).__init__()
|
60 |
-
self.num_classes = num_classes
|
61 |
-
self.cls_out_channels = num_classes
|
62 |
-
self.in_channels = in_channels
|
63 |
-
self.feat_channels = feat_channels
|
64 |
-
self.stacked_convs = stacked_convs
|
65 |
-
self.strides = strides
|
66 |
-
self.dcn_on_last_conv = dcn_on_last_conv
|
67 |
-
assert conv_bias == 'auto' or isinstance(conv_bias, bool)
|
68 |
-
self.conv_bias = conv_bias
|
69 |
-
self.loss_cls = build_loss(loss_cls)
|
70 |
-
self.loss_bbox = build_loss(loss_bbox)
|
71 |
-
self.train_cfg = train_cfg
|
72 |
-
self.test_cfg = test_cfg
|
73 |
-
self.conv_cfg = conv_cfg
|
74 |
-
self.norm_cfg = norm_cfg
|
75 |
-
self.fp16_enabled = False
|
76 |
-
|
77 |
-
self._init_layers()
|
78 |
-
|
79 |
-
def _init_layers(self):
|
80 |
-
"""Initialize layers of the head."""
|
81 |
-
self._init_cls_convs()
|
82 |
-
self._init_reg_convs()
|
83 |
-
self._init_predictor()
|
84 |
-
|
85 |
-
def _init_cls_convs(self):
|
86 |
-
"""Initialize classification conv layers of the head."""
|
87 |
-
self.cls_convs = nn.ModuleList()
|
88 |
-
for i in range(self.stacked_convs):
|
89 |
-
chn = self.in_channels if i == 0 else self.feat_channels
|
90 |
-
if self.dcn_on_last_conv and i == self.stacked_convs - 1:
|
91 |
-
conv_cfg = dict(type='DCNv2')
|
92 |
-
else:
|
93 |
-
conv_cfg = self.conv_cfg
|
94 |
-
self.cls_convs.append(
|
95 |
-
ConvModule(
|
96 |
-
chn,
|
97 |
-
self.feat_channels,
|
98 |
-
3,
|
99 |
-
stride=1,
|
100 |
-
padding=1,
|
101 |
-
conv_cfg=conv_cfg,
|
102 |
-
norm_cfg=self.norm_cfg,
|
103 |
-
bias=self.conv_bias))
|
104 |
-
|
105 |
-
def _init_reg_convs(self):
|
106 |
-
"""Initialize bbox regression conv layers of the head."""
|
107 |
-
self.reg_convs = nn.ModuleList()
|
108 |
-
for i in range(self.stacked_convs):
|
109 |
-
chn = self.in_channels if i == 0 else self.feat_channels
|
110 |
-
if self.dcn_on_last_conv and i == self.stacked_convs - 1:
|
111 |
-
conv_cfg = dict(type='DCNv2')
|
112 |
-
else:
|
113 |
-
conv_cfg = self.conv_cfg
|
114 |
-
self.reg_convs.append(
|
115 |
-
ConvModule(
|
116 |
-
chn,
|
117 |
-
self.feat_channels,
|
118 |
-
3,
|
119 |
-
stride=1,
|
120 |
-
padding=1,
|
121 |
-
conv_cfg=conv_cfg,
|
122 |
-
norm_cfg=self.norm_cfg,
|
123 |
-
bias=self.conv_bias))
|
124 |
-
|
125 |
-
def _init_predictor(self):
|
126 |
-
"""Initialize predictor layers of the head."""
|
127 |
-
self.conv_cls = nn.Conv2d(
|
128 |
-
self.feat_channels, self.cls_out_channels, 3, padding=1)
|
129 |
-
self.conv_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1)
|
130 |
-
|
131 |
-
def init_weights(self):
|
132 |
-
"""Initialize weights of the head."""
|
133 |
-
for m in self.cls_convs:
|
134 |
-
if isinstance(m.conv, nn.Conv2d):
|
135 |
-
normal_init(m.conv, std=0.01)
|
136 |
-
for m in self.reg_convs:
|
137 |
-
if isinstance(m.conv, nn.Conv2d):
|
138 |
-
normal_init(m.conv, std=0.01)
|
139 |
-
bias_cls = bias_init_with_prob(0.01)
|
140 |
-
normal_init(self.conv_cls, std=0.01, bias=bias_cls)
|
141 |
-
normal_init(self.conv_reg, std=0.01)
|
142 |
-
|
143 |
-
def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict,
|
144 |
-
missing_keys, unexpected_keys, error_msgs):
|
145 |
-
"""Hack some keys of the model state dict so that can load checkpoints
|
146 |
-
of previous version."""
|
147 |
-
version = local_metadata.get('version', None)
|
148 |
-
if version is None:
|
149 |
-
# the key is different in early versions
|
150 |
-
# for example, 'fcos_cls' become 'conv_cls' now
|
151 |
-
bbox_head_keys = [
|
152 |
-
k for k in state_dict.keys() if k.startswith(prefix)
|
153 |
-
]
|
154 |
-
ori_predictor_keys = []
|
155 |
-
new_predictor_keys = []
|
156 |
-
# e.g. 'fcos_cls' or 'fcos_reg'
|
157 |
-
for key in bbox_head_keys:
|
158 |
-
ori_predictor_keys.append(key)
|
159 |
-
key = key.split('.')
|
160 |
-
conv_name = None
|
161 |
-
if key[1].endswith('cls'):
|
162 |
-
conv_name = 'conv_cls'
|
163 |
-
elif key[1].endswith('reg'):
|
164 |
-
conv_name = 'conv_reg'
|
165 |
-
elif key[1].endswith('centerness'):
|
166 |
-
conv_name = 'conv_centerness'
|
167 |
-
else:
|
168 |
-
assert NotImplementedError
|
169 |
-
if conv_name is not None:
|
170 |
-
key[1] = conv_name
|
171 |
-
new_predictor_keys.append('.'.join(key))
|
172 |
-
else:
|
173 |
-
ori_predictor_keys.pop(-1)
|
174 |
-
for i in range(len(new_predictor_keys)):
|
175 |
-
state_dict[new_predictor_keys[i]] = state_dict.pop(
|
176 |
-
ori_predictor_keys[i])
|
177 |
-
super()._load_from_state_dict(state_dict, prefix, local_metadata,
|
178 |
-
strict, missing_keys, unexpected_keys,
|
179 |
-
error_msgs)
|
180 |
-
|
181 |
-
def forward(self, feats):
|
182 |
-
"""Forward features from the upstream network.
|
183 |
-
|
184 |
-
Args:
|
185 |
-
feats (tuple[Tensor]): Features from the upstream network, each is
|
186 |
-
a 4D-tensor.
|
187 |
-
|
188 |
-
Returns:
|
189 |
-
tuple: Usually contain classification scores and bbox predictions.
|
190 |
-
cls_scores (list[Tensor]): Box scores for each scale level,
|
191 |
-
each is a 4D-tensor, the channel number is
|
192 |
-
num_points * num_classes.
|
193 |
-
bbox_preds (list[Tensor]): Box energies / deltas for each scale
|
194 |
-
level, each is a 4D-tensor, the channel number is
|
195 |
-
num_points * 4.
|
196 |
-
"""
|
197 |
-
return multi_apply(self.forward_single, feats)[:2]
|
198 |
-
|
199 |
-
def forward_single(self, x):
|
200 |
-
"""Forward features of a single scale level.
|
201 |
-
|
202 |
-
Args:
|
203 |
-
x (Tensor): FPN feature maps of the specified stride.
|
204 |
-
|
205 |
-
Returns:
|
206 |
-
tuple: Scores for each class, bbox predictions, features
|
207 |
-
after classification and regression conv layers, some
|
208 |
-
models needs these features like FCOS.
|
209 |
-
"""
|
210 |
-
cls_feat = x
|
211 |
-
reg_feat = x
|
212 |
-
|
213 |
-
for cls_layer in self.cls_convs:
|
214 |
-
cls_feat = cls_layer(cls_feat)
|
215 |
-
cls_score = self.conv_cls(cls_feat)
|
216 |
-
|
217 |
-
for reg_layer in self.reg_convs:
|
218 |
-
reg_feat = reg_layer(reg_feat)
|
219 |
-
bbox_pred = self.conv_reg(reg_feat)
|
220 |
-
return cls_score, bbox_pred, cls_feat, reg_feat
|
221 |
-
|
222 |
-
@abstractmethod
|
223 |
-
@force_fp32(apply_to=('cls_scores', 'bbox_preds'))
|
224 |
-
def loss(self,
|
225 |
-
cls_scores,
|
226 |
-
bbox_preds,
|
227 |
-
gt_bboxes,
|
228 |
-
gt_labels,
|
229 |
-
img_metas,
|
230 |
-
gt_bboxes_ignore=None):
|
231 |
-
"""Compute loss of the head.
|
232 |
-
|
233 |
-
Args:
|
234 |
-
cls_scores (list[Tensor]): Box scores for each scale level,
|
235 |
-
each is a 4D-tensor, the channel number is
|
236 |
-
num_points * num_classes.
|
237 |
-
bbox_preds (list[Tensor]): Box energies / deltas for each scale
|
238 |
-
level, each is a 4D-tensor, the channel number is
|
239 |
-
num_points * 4.
|
240 |
-
gt_bboxes (list[Tensor]): Ground truth bboxes for each image with
|
241 |
-
shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format.
|
242 |
-
gt_labels (list[Tensor]): class indices corresponding to each box
|
243 |
-
img_metas (list[dict]): Meta information of each image, e.g.,
|
244 |
-
image size, scaling factor, etc.
|
245 |
-
gt_bboxes_ignore (None | list[Tensor]): specify which bounding
|
246 |
-
boxes can be ignored when computing the loss.
|
247 |
-
"""
|
248 |
-
|
249 |
-
raise NotImplementedError
|
250 |
-
|
251 |
-
@abstractmethod
|
252 |
-
@force_fp32(apply_to=('cls_scores', 'bbox_preds'))
|
253 |
-
def get_bboxes(self,
|
254 |
-
cls_scores,
|
255 |
-
bbox_preds,
|
256 |
-
img_metas,
|
257 |
-
cfg=None,
|
258 |
-
rescale=None):
|
259 |
-
"""Transform network output for a batch into bbox predictions.
|
260 |
-
|
261 |
-
Args:
|
262 |
-
cls_scores (list[Tensor]): Box scores for each scale level
|
263 |
-
Has shape (N, num_points * num_classes, H, W)
|
264 |
-
bbox_preds (list[Tensor]): Box energies / deltas for each scale
|
265 |
-
level with shape (N, num_points * 4, H, W)
|
266 |
-
img_metas (list[dict]): Meta information of each image, e.g.,
|
267 |
-
image size, scaling factor, etc.
|
268 |
-
cfg (mmcv.Config): Test / postprocessing configuration,
|
269 |
-
if None, test_cfg would be used
|
270 |
-
rescale (bool): If True, return boxes in original image space
|
271 |
-
"""
|
272 |
-
|
273 |
-
raise NotImplementedError
|
274 |
-
|
275 |
-
@abstractmethod
|
276 |
-
def get_targets(self, points, gt_bboxes_list, gt_labels_list):
|
277 |
-
"""Compute regression, classification and centerness targets for points
|
278 |
-
in multiple images.
|
279 |
-
|
280 |
-
Args:
|
281 |
-
points (list[Tensor]): Points of each fpn level, each has shape
|
282 |
-
(num_points, 2).
|
283 |
-
gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image,
|
284 |
-
each has shape (num_gt, 4).
|
285 |
-
gt_labels_list (list[Tensor]): Ground truth labels of each box,
|
286 |
-
each has shape (num_gt,).
|
287 |
-
"""
|
288 |
-
raise NotImplementedError
|
289 |
-
|
290 |
-
def _get_points_single(self,
|
291 |
-
featmap_size,
|
292 |
-
stride,
|
293 |
-
dtype,
|
294 |
-
device,
|
295 |
-
flatten=False):
|
296 |
-
"""Get points of a single scale level."""
|
297 |
-
h, w = featmap_size
|
298 |
-
x_range = torch.arange(w, dtype=dtype, device=device)
|
299 |
-
y_range = torch.arange(h, dtype=dtype, device=device)
|
300 |
-
y, x = torch.meshgrid(y_range, x_range)
|
301 |
-
if flatten:
|
302 |
-
y = y.flatten()
|
303 |
-
x = x.flatten()
|
304 |
-
return y, x
|
305 |
-
|
306 |
-
def get_points(self, featmap_sizes, dtype, device, flatten=False):
|
307 |
-
"""Get points according to feature map sizes.
|
308 |
-
|
309 |
-
Args:
|
310 |
-
featmap_sizes (list[tuple]): Multi-level feature map sizes.
|
311 |
-
dtype (torch.dtype): Type of points.
|
312 |
-
device (torch.device): Device of points.
|
313 |
-
|
314 |
-
Returns:
|
315 |
-
tuple: points of each image.
|
316 |
-
"""
|
317 |
-
mlvl_points = []
|
318 |
-
for i in range(len(featmap_sizes)):
|
319 |
-
mlvl_points.append(
|
320 |
-
self._get_points_single(featmap_sizes[i], self.strides[i],
|
321 |
-
dtype, device, flatten))
|
322 |
-
return mlvl_points
|
323 |
-
|
324 |
-
def aug_test(self, feats, img_metas, rescale=False):
|
325 |
-
"""Test function with test time augmentation.
|
326 |
-
|
327 |
-
Args:
|
328 |
-
feats (list[Tensor]): the outer list indicates test-time
|
329 |
-
augmentations and inner Tensor should have a shape NxCxHxW,
|
330 |
-
which contains features for all images in the batch.
|
331 |
-
img_metas (list[list[dict]]): the outer list indicates test-time
|
332 |
-
augs (multiscale, flip, etc.) and the inner list indicates
|
333 |
-
images in a batch. each dict has image information.
|
334 |
-
rescale (bool, optional): Whether to rescale the results.
|
335 |
-
Defaults to False.
|
336 |
-
|
337 |
-
Returns:
|
338 |
-
list[ndarray]: bbox results of each class
|
339 |
-
"""
|
340 |
-
return self.aug_test_bboxes(feats, img_metas, rescale=rescale)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/lama-example/saicinpainting/evaluation/masks/mask.py
DELETED
@@ -1,429 +0,0 @@
|
|
1 |
-
import enum
|
2 |
-
from copy import deepcopy
|
3 |
-
|
4 |
-
import numpy as np
|
5 |
-
from skimage import img_as_ubyte
|
6 |
-
from skimage.transform import rescale, resize
|
7 |
-
try:
|
8 |
-
from detectron2 import model_zoo
|
9 |
-
from detectron2.config import get_cfg
|
10 |
-
from detectron2.engine import DefaultPredictor
|
11 |
-
DETECTRON_INSTALLED = True
|
12 |
-
except:
|
13 |
-
print("Detectron v2 is not installed")
|
14 |
-
DETECTRON_INSTALLED = False
|
15 |
-
|
16 |
-
from .countless.countless2d import zero_corrected_countless
|
17 |
-
|
18 |
-
|
19 |
-
class ObjectMask():
|
20 |
-
def __init__(self, mask):
|
21 |
-
self.height, self.width = mask.shape
|
22 |
-
(self.up, self.down), (self.left, self.right) = self._get_limits(mask)
|
23 |
-
self.mask = mask[self.up:self.down, self.left:self.right].copy()
|
24 |
-
|
25 |
-
@staticmethod
|
26 |
-
def _get_limits(mask):
|
27 |
-
def indicator_limits(indicator):
|
28 |
-
lower = indicator.argmax()
|
29 |
-
upper = len(indicator) - indicator[::-1].argmax()
|
30 |
-
return lower, upper
|
31 |
-
|
32 |
-
vertical_indicator = mask.any(axis=1)
|
33 |
-
vertical_limits = indicator_limits(vertical_indicator)
|
34 |
-
|
35 |
-
horizontal_indicator = mask.any(axis=0)
|
36 |
-
horizontal_limits = indicator_limits(horizontal_indicator)
|
37 |
-
|
38 |
-
return vertical_limits, horizontal_limits
|
39 |
-
|
40 |
-
def _clean(self):
|
41 |
-
self.up, self.down, self.left, self.right = 0, 0, 0, 0
|
42 |
-
self.mask = np.empty((0, 0))
|
43 |
-
|
44 |
-
def horizontal_flip(self, inplace=False):
|
45 |
-
if not inplace:
|
46 |
-
flipped = deepcopy(self)
|
47 |
-
return flipped.horizontal_flip(inplace=True)
|
48 |
-
|
49 |
-
self.mask = self.mask[:, ::-1]
|
50 |
-
return self
|
51 |
-
|
52 |
-
def vertical_flip(self, inplace=False):
|
53 |
-
if not inplace:
|
54 |
-
flipped = deepcopy(self)
|
55 |
-
return flipped.vertical_flip(inplace=True)
|
56 |
-
|
57 |
-
self.mask = self.mask[::-1, :]
|
58 |
-
return self
|
59 |
-
|
60 |
-
def image_center(self):
|
61 |
-
y_center = self.up + (self.down - self.up) / 2
|
62 |
-
x_center = self.left + (self.right - self.left) / 2
|
63 |
-
return y_center, x_center
|
64 |
-
|
65 |
-
def rescale(self, scaling_factor, inplace=False):
|
66 |
-
if not inplace:
|
67 |
-
scaled = deepcopy(self)
|
68 |
-
return scaled.rescale(scaling_factor, inplace=True)
|
69 |
-
|
70 |
-
scaled_mask = rescale(self.mask.astype(float), scaling_factor, order=0) > 0.5
|
71 |
-
(up, down), (left, right) = self._get_limits(scaled_mask)
|
72 |
-
self.mask = scaled_mask[up:down, left:right]
|
73 |
-
|
74 |
-
y_center, x_center = self.image_center()
|
75 |
-
mask_height, mask_width = self.mask.shape
|
76 |
-
self.up = int(round(y_center - mask_height / 2))
|
77 |
-
self.down = self.up + mask_height
|
78 |
-
self.left = int(round(x_center - mask_width / 2))
|
79 |
-
self.right = self.left + mask_width
|
80 |
-
return self
|
81 |
-
|
82 |
-
def crop_to_canvas(self, vertical=True, horizontal=True, inplace=False):
|
83 |
-
if not inplace:
|
84 |
-
cropped = deepcopy(self)
|
85 |
-
cropped.crop_to_canvas(vertical=vertical, horizontal=horizontal, inplace=True)
|
86 |
-
return cropped
|
87 |
-
|
88 |
-
if vertical:
|
89 |
-
if self.up >= self.height or self.down <= 0:
|
90 |
-
self._clean()
|
91 |
-
else:
|
92 |
-
cut_up, cut_down = max(-self.up, 0), max(self.down - self.height, 0)
|
93 |
-
if cut_up != 0:
|
94 |
-
self.mask = self.mask[cut_up:]
|
95 |
-
self.up = 0
|
96 |
-
if cut_down != 0:
|
97 |
-
self.mask = self.mask[:-cut_down]
|
98 |
-
self.down = self.height
|
99 |
-
|
100 |
-
if horizontal:
|
101 |
-
if self.left >= self.width or self.right <= 0:
|
102 |
-
self._clean()
|
103 |
-
else:
|
104 |
-
cut_left, cut_right = max(-self.left, 0), max(self.right - self.width, 0)
|
105 |
-
if cut_left != 0:
|
106 |
-
self.mask = self.mask[:, cut_left:]
|
107 |
-
self.left = 0
|
108 |
-
if cut_right != 0:
|
109 |
-
self.mask = self.mask[:, :-cut_right]
|
110 |
-
self.right = self.width
|
111 |
-
|
112 |
-
return self
|
113 |
-
|
114 |
-
def restore_full_mask(self, allow_crop=False):
|
115 |
-
cropped = self.crop_to_canvas(inplace=allow_crop)
|
116 |
-
mask = np.zeros((cropped.height, cropped.width), dtype=bool)
|
117 |
-
mask[cropped.up:cropped.down, cropped.left:cropped.right] = cropped.mask
|
118 |
-
return mask
|
119 |
-
|
120 |
-
def shift(self, vertical=0, horizontal=0, inplace=False):
|
121 |
-
if not inplace:
|
122 |
-
shifted = deepcopy(self)
|
123 |
-
return shifted.shift(vertical=vertical, horizontal=horizontal, inplace=True)
|
124 |
-
|
125 |
-
self.up += vertical
|
126 |
-
self.down += vertical
|
127 |
-
self.left += horizontal
|
128 |
-
self.right += horizontal
|
129 |
-
return self
|
130 |
-
|
131 |
-
def area(self):
|
132 |
-
return self.mask.sum()
|
133 |
-
|
134 |
-
|
135 |
-
class RigidnessMode(enum.Enum):
|
136 |
-
soft = 0
|
137 |
-
rigid = 1
|
138 |
-
|
139 |
-
|
140 |
-
class SegmentationMask:
|
141 |
-
def __init__(self, confidence_threshold=0.5, rigidness_mode=RigidnessMode.rigid,
|
142 |
-
max_object_area=0.3, min_mask_area=0.02, downsample_levels=6, num_variants_per_mask=4,
|
143 |
-
max_mask_intersection=0.5, max_foreground_coverage=0.5, max_foreground_intersection=0.5,
|
144 |
-
max_hidden_area=0.2, max_scale_change=0.25, horizontal_flip=True,
|
145 |
-
max_vertical_shift=0.1, position_shuffle=True):
|
146 |
-
"""
|
147 |
-
:param confidence_threshold: float; threshold for confidence of the panoptic segmentator to allow for
|
148 |
-
the instance.
|
149 |
-
:param rigidness_mode: RigidnessMode object
|
150 |
-
when soft, checks intersection only with the object from which the mask_object was produced
|
151 |
-
when rigid, checks intersection with any foreground class object
|
152 |
-
:param max_object_area: float; allowed upper bound for to be considered as mask_object.
|
153 |
-
:param min_mask_area: float; lower bound for mask to be considered valid
|
154 |
-
:param downsample_levels: int; defines width of the resized segmentation to obtain shifted masks;
|
155 |
-
:param num_variants_per_mask: int; maximal number of the masks for the same object;
|
156 |
-
:param max_mask_intersection: float; maximum allowed area fraction of intersection for 2 masks
|
157 |
-
produced by horizontal shift of the same mask_object; higher value -> more diversity
|
158 |
-
:param max_foreground_coverage: float; maximum allowed area fraction of intersection for foreground object to be
|
159 |
-
covered by mask; lower value -> less the objects are covered
|
160 |
-
:param max_foreground_intersection: float; maximum allowed area of intersection for the mask with foreground
|
161 |
-
object; lower value -> mask is more on the background than on the objects
|
162 |
-
:param max_hidden_area: upper bound on part of the object hidden by shifting object outside the screen area;
|
163 |
-
:param max_scale_change: allowed scale change for the mask_object;
|
164 |
-
:param horizontal_flip: if horizontal flips are allowed;
|
165 |
-
:param max_vertical_shift: amount of vertical movement allowed;
|
166 |
-
:param position_shuffle: shuffle
|
167 |
-
"""
|
168 |
-
|
169 |
-
assert DETECTRON_INSTALLED, 'Cannot use SegmentationMask without detectron2'
|
170 |
-
self.cfg = get_cfg()
|
171 |
-
self.cfg.merge_from_file(model_zoo.get_config_file("COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml"))
|
172 |
-
self.cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml")
|
173 |
-
self.cfg.MODEL.PANOPTIC_FPN.COMBINE.INSTANCES_CONFIDENCE_THRESH = confidence_threshold
|
174 |
-
self.predictor = DefaultPredictor(self.cfg)
|
175 |
-
|
176 |
-
self.rigidness_mode = RigidnessMode(rigidness_mode)
|
177 |
-
self.max_object_area = max_object_area
|
178 |
-
self.min_mask_area = min_mask_area
|
179 |
-
self.downsample_levels = downsample_levels
|
180 |
-
self.num_variants_per_mask = num_variants_per_mask
|
181 |
-
self.max_mask_intersection = max_mask_intersection
|
182 |
-
self.max_foreground_coverage = max_foreground_coverage
|
183 |
-
self.max_foreground_intersection = max_foreground_intersection
|
184 |
-
self.max_hidden_area = max_hidden_area
|
185 |
-
self.position_shuffle = position_shuffle
|
186 |
-
|
187 |
-
self.max_scale_change = max_scale_change
|
188 |
-
self.horizontal_flip = horizontal_flip
|
189 |
-
self.max_vertical_shift = max_vertical_shift
|
190 |
-
|
191 |
-
def get_segmentation(self, img):
|
192 |
-
im = img_as_ubyte(img)
|
193 |
-
panoptic_seg, segment_info = self.predictor(im)["panoptic_seg"]
|
194 |
-
return panoptic_seg, segment_info
|
195 |
-
|
196 |
-
@staticmethod
|
197 |
-
def _is_power_of_two(n):
|
198 |
-
return (n != 0) and (n & (n-1) == 0)
|
199 |
-
|
200 |
-
def identify_candidates(self, panoptic_seg, segments_info):
|
201 |
-
potential_mask_ids = []
|
202 |
-
for segment in segments_info:
|
203 |
-
if not segment["isthing"]:
|
204 |
-
continue
|
205 |
-
mask = (panoptic_seg == segment["id"]).int().detach().cpu().numpy()
|
206 |
-
area = mask.sum().item() / np.prod(panoptic_seg.shape)
|
207 |
-
if area >= self.max_object_area:
|
208 |
-
continue
|
209 |
-
potential_mask_ids.append(segment["id"])
|
210 |
-
return potential_mask_ids
|
211 |
-
|
212 |
-
def downsample_mask(self, mask):
|
213 |
-
height, width = mask.shape
|
214 |
-
if not (self._is_power_of_two(height) and self._is_power_of_two(width)):
|
215 |
-
raise ValueError("Image sides are not power of 2.")
|
216 |
-
|
217 |
-
num_iterations = width.bit_length() - 1 - self.downsample_levels
|
218 |
-
if num_iterations < 0:
|
219 |
-
raise ValueError(f"Width is lower than 2^{self.downsample_levels}.")
|
220 |
-
|
221 |
-
if height.bit_length() - 1 < num_iterations:
|
222 |
-
raise ValueError("Height is too low to perform downsampling")
|
223 |
-
|
224 |
-
downsampled = mask
|
225 |
-
for _ in range(num_iterations):
|
226 |
-
downsampled = zero_corrected_countless(downsampled)
|
227 |
-
|
228 |
-
return downsampled
|
229 |
-
|
230 |
-
def _augmentation_params(self):
|
231 |
-
scaling_factor = np.random.uniform(1 - self.max_scale_change, 1 + self.max_scale_change)
|
232 |
-
if self.horizontal_flip:
|
233 |
-
horizontal_flip = bool(np.random.choice(2))
|
234 |
-
else:
|
235 |
-
horizontal_flip = False
|
236 |
-
vertical_shift = np.random.uniform(-self.max_vertical_shift, self.max_vertical_shift)
|
237 |
-
|
238 |
-
return {
|
239 |
-
"scaling_factor": scaling_factor,
|
240 |
-
"horizontal_flip": horizontal_flip,
|
241 |
-
"vertical_shift": vertical_shift
|
242 |
-
}
|
243 |
-
|
244 |
-
def _get_intersection(self, mask_array, mask_object):
|
245 |
-
intersection = mask_array[
|
246 |
-
mask_object.up:mask_object.down, mask_object.left:mask_object.right
|
247 |
-
] & mask_object.mask
|
248 |
-
return intersection
|
249 |
-
|
250 |
-
def _check_masks_intersection(self, aug_mask, total_mask_area, prev_masks):
|
251 |
-
for existing_mask in prev_masks:
|
252 |
-
intersection_area = self._get_intersection(existing_mask, aug_mask).sum()
|
253 |
-
intersection_existing = intersection_area / existing_mask.sum()
|
254 |
-
intersection_current = 1 - (aug_mask.area() - intersection_area) / total_mask_area
|
255 |
-
if (intersection_existing > self.max_mask_intersection) or \
|
256 |
-
(intersection_current > self.max_mask_intersection):
|
257 |
-
return False
|
258 |
-
return True
|
259 |
-
|
260 |
-
def _check_foreground_intersection(self, aug_mask, foreground):
|
261 |
-
for existing_mask in foreground:
|
262 |
-
intersection_area = self._get_intersection(existing_mask, aug_mask).sum()
|
263 |
-
intersection_existing = intersection_area / existing_mask.sum()
|
264 |
-
if intersection_existing > self.max_foreground_coverage:
|
265 |
-
return False
|
266 |
-
intersection_mask = intersection_area / aug_mask.area()
|
267 |
-
if intersection_mask > self.max_foreground_intersection:
|
268 |
-
return False
|
269 |
-
return True
|
270 |
-
|
271 |
-
def _move_mask(self, mask, foreground):
|
272 |
-
# Obtaining properties of the original mask_object:
|
273 |
-
orig_mask = ObjectMask(mask)
|
274 |
-
|
275 |
-
chosen_masks = []
|
276 |
-
chosen_parameters = []
|
277 |
-
# to fix the case when resizing gives mask_object consisting only of False
|
278 |
-
scaling_factor_lower_bound = 0.
|
279 |
-
|
280 |
-
for var_idx in range(self.num_variants_per_mask):
|
281 |
-
# Obtaining augmentation parameters and applying them to the downscaled mask_object
|
282 |
-
augmentation_params = self._augmentation_params()
|
283 |
-
augmentation_params["scaling_factor"] = min([
|
284 |
-
augmentation_params["scaling_factor"],
|
285 |
-
2 * min(orig_mask.up, orig_mask.height - orig_mask.down) / orig_mask.height + 1.,
|
286 |
-
2 * min(orig_mask.left, orig_mask.width - orig_mask.right) / orig_mask.width + 1.
|
287 |
-
])
|
288 |
-
augmentation_params["scaling_factor"] = max([
|
289 |
-
augmentation_params["scaling_factor"], scaling_factor_lower_bound
|
290 |
-
])
|
291 |
-
|
292 |
-
aug_mask = deepcopy(orig_mask)
|
293 |
-
aug_mask.rescale(augmentation_params["scaling_factor"], inplace=True)
|
294 |
-
if augmentation_params["horizontal_flip"]:
|
295 |
-
aug_mask.horizontal_flip(inplace=True)
|
296 |
-
total_aug_area = aug_mask.area()
|
297 |
-
if total_aug_area == 0:
|
298 |
-
scaling_factor_lower_bound = 1.
|
299 |
-
continue
|
300 |
-
|
301 |
-
# Fix if the element vertical shift is too strong and shown area is too small:
|
302 |
-
vertical_area = aug_mask.mask.sum(axis=1) / total_aug_area # share of area taken by rows
|
303 |
-
# number of rows which are allowed to be hidden from upper and lower parts of image respectively
|
304 |
-
max_hidden_up = np.searchsorted(vertical_area.cumsum(), self.max_hidden_area)
|
305 |
-
max_hidden_down = np.searchsorted(vertical_area[::-1].cumsum(), self.max_hidden_area)
|
306 |
-
# correcting vertical shift, so not too much area will be hidden
|
307 |
-
augmentation_params["vertical_shift"] = np.clip(
|
308 |
-
augmentation_params["vertical_shift"],
|
309 |
-
-(aug_mask.up + max_hidden_up) / aug_mask.height,
|
310 |
-
(aug_mask.height - aug_mask.down + max_hidden_down) / aug_mask.height
|
311 |
-
)
|
312 |
-
# Applying vertical shift:
|
313 |
-
vertical_shift = int(round(aug_mask.height * augmentation_params["vertical_shift"]))
|
314 |
-
aug_mask.shift(vertical=vertical_shift, inplace=True)
|
315 |
-
aug_mask.crop_to_canvas(vertical=True, horizontal=False, inplace=True)
|
316 |
-
|
317 |
-
# Choosing horizontal shift:
|
318 |
-
max_hidden_area = self.max_hidden_area - (1 - aug_mask.area() / total_aug_area)
|
319 |
-
horizontal_area = aug_mask.mask.sum(axis=0) / total_aug_area
|
320 |
-
max_hidden_left = np.searchsorted(horizontal_area.cumsum(), max_hidden_area)
|
321 |
-
max_hidden_right = np.searchsorted(horizontal_area[::-1].cumsum(), max_hidden_area)
|
322 |
-
allowed_shifts = np.arange(-max_hidden_left, aug_mask.width -
|
323 |
-
(aug_mask.right - aug_mask.left) + max_hidden_right + 1)
|
324 |
-
allowed_shifts = - (aug_mask.left - allowed_shifts)
|
325 |
-
|
326 |
-
if self.position_shuffle:
|
327 |
-
np.random.shuffle(allowed_shifts)
|
328 |
-
|
329 |
-
mask_is_found = False
|
330 |
-
for horizontal_shift in allowed_shifts:
|
331 |
-
aug_mask_left = deepcopy(aug_mask)
|
332 |
-
aug_mask_left.shift(horizontal=horizontal_shift, inplace=True)
|
333 |
-
aug_mask_left.crop_to_canvas(inplace=True)
|
334 |
-
|
335 |
-
prev_masks = [mask] + chosen_masks
|
336 |
-
is_mask_suitable = self._check_masks_intersection(aug_mask_left, total_aug_area, prev_masks) & \
|
337 |
-
self._check_foreground_intersection(aug_mask_left, foreground)
|
338 |
-
if is_mask_suitable:
|
339 |
-
aug_draw = aug_mask_left.restore_full_mask()
|
340 |
-
chosen_masks.append(aug_draw)
|
341 |
-
augmentation_params["horizontal_shift"] = horizontal_shift / aug_mask_left.width
|
342 |
-
chosen_parameters.append(augmentation_params)
|
343 |
-
mask_is_found = True
|
344 |
-
break
|
345 |
-
|
346 |
-
if not mask_is_found:
|
347 |
-
break
|
348 |
-
|
349 |
-
return chosen_parameters
|
350 |
-
|
351 |
-
def _prepare_mask(self, mask):
|
352 |
-
height, width = mask.shape
|
353 |
-
target_width = width if self._is_power_of_two(width) else (1 << width.bit_length())
|
354 |
-
target_height = height if self._is_power_of_two(height) else (1 << height.bit_length())
|
355 |
-
|
356 |
-
return resize(mask.astype('float32'), (target_height, target_width), order=0, mode='edge').round().astype('int32')
|
357 |
-
|
358 |
-
def get_masks(self, im, return_panoptic=False):
|
359 |
-
panoptic_seg, segments_info = self.get_segmentation(im)
|
360 |
-
potential_mask_ids = self.identify_candidates(panoptic_seg, segments_info)
|
361 |
-
|
362 |
-
panoptic_seg_scaled = self._prepare_mask(panoptic_seg.detach().cpu().numpy())
|
363 |
-
downsampled = self.downsample_mask(panoptic_seg_scaled)
|
364 |
-
scene_objects = []
|
365 |
-
for segment in segments_info:
|
366 |
-
if not segment["isthing"]:
|
367 |
-
continue
|
368 |
-
mask = downsampled == segment["id"]
|
369 |
-
if not np.any(mask):
|
370 |
-
continue
|
371 |
-
scene_objects.append(mask)
|
372 |
-
|
373 |
-
mask_set = []
|
374 |
-
for mask_id in potential_mask_ids:
|
375 |
-
mask = downsampled == mask_id
|
376 |
-
if not np.any(mask):
|
377 |
-
continue
|
378 |
-
|
379 |
-
if self.rigidness_mode is RigidnessMode.soft:
|
380 |
-
foreground = [mask]
|
381 |
-
elif self.rigidness_mode is RigidnessMode.rigid:
|
382 |
-
foreground = scene_objects
|
383 |
-
else:
|
384 |
-
raise ValueError(f'Unexpected rigidness_mode: {rigidness_mode}')
|
385 |
-
|
386 |
-
masks_params = self._move_mask(mask, foreground)
|
387 |
-
|
388 |
-
full_mask = ObjectMask((panoptic_seg == mask_id).detach().cpu().numpy())
|
389 |
-
|
390 |
-
for params in masks_params:
|
391 |
-
aug_mask = deepcopy(full_mask)
|
392 |
-
aug_mask.rescale(params["scaling_factor"], inplace=True)
|
393 |
-
if params["horizontal_flip"]:
|
394 |
-
aug_mask.horizontal_flip(inplace=True)
|
395 |
-
|
396 |
-
vertical_shift = int(round(aug_mask.height * params["vertical_shift"]))
|
397 |
-
horizontal_shift = int(round(aug_mask.width * params["horizontal_shift"]))
|
398 |
-
aug_mask.shift(vertical=vertical_shift, horizontal=horizontal_shift, inplace=True)
|
399 |
-
aug_mask = aug_mask.restore_full_mask().astype('uint8')
|
400 |
-
if aug_mask.mean() <= self.min_mask_area:
|
401 |
-
continue
|
402 |
-
mask_set.append(aug_mask)
|
403 |
-
|
404 |
-
if return_panoptic:
|
405 |
-
return mask_set, panoptic_seg.detach().cpu().numpy()
|
406 |
-
else:
|
407 |
-
return mask_set
|
408 |
-
|
409 |
-
|
410 |
-
def propose_random_square_crop(mask, min_overlap=0.5):
|
411 |
-
height, width = mask.shape
|
412 |
-
mask_ys, mask_xs = np.where(mask > 0.5) # mask==0 is known fragment and mask==1 is missing
|
413 |
-
|
414 |
-
if height < width:
|
415 |
-
crop_size = height
|
416 |
-
obj_left, obj_right = mask_xs.min(), mask_xs.max()
|
417 |
-
obj_width = obj_right - obj_left
|
418 |
-
left_border = max(0, min(width - crop_size - 1, obj_left + obj_width * min_overlap - crop_size))
|
419 |
-
right_border = max(left_border + 1, min(width - crop_size, obj_left + obj_width * min_overlap))
|
420 |
-
start_x = np.random.randint(left_border, right_border)
|
421 |
-
return start_x, 0, start_x + crop_size, height
|
422 |
-
else:
|
423 |
-
crop_size = width
|
424 |
-
obj_top, obj_bottom = mask_ys.min(), mask_ys.max()
|
425 |
-
obj_height = obj_bottom - obj_top
|
426 |
-
top_border = max(0, min(height - crop_size - 1, obj_top + obj_height * min_overlap - crop_size))
|
427 |
-
bottom_border = max(top_border + 1, min(height - crop_size, obj_top + obj_height * min_overlap))
|
428 |
-
start_y = np.random.randint(top_border, bottom_border)
|
429 |
-
return 0, start_y, width, start_y + crop_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/transfiner/configs/Misc/torchvision_imagenet_R_50.py
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
"""
|
2 |
-
An example config file to train a ImageNet classifier with detectron2.
|
3 |
-
Model and dataloader both come from torchvision.
|
4 |
-
This shows how to use detectron2 as a general engine for any new models and tasks.
|
5 |
-
|
6 |
-
To run, use the following command:
|
7 |
-
|
8 |
-
python tools/lazyconfig_train_net.py --config-file configs/Misc/torchvision_imagenet_R_50.py \
|
9 |
-
--num-gpus 8 dataloader.train.dataset.root=/path/to/imagenet/
|
10 |
-
|
11 |
-
"""
|
12 |
-
|
13 |
-
|
14 |
-
import torch
|
15 |
-
from torch import nn
|
16 |
-
from torch.nn import functional as F
|
17 |
-
from omegaconf import OmegaConf
|
18 |
-
import torchvision
|
19 |
-
from torchvision.transforms import transforms as T
|
20 |
-
from torchvision.models.resnet import ResNet, Bottleneck
|
21 |
-
from fvcore.common.param_scheduler import MultiStepParamScheduler
|
22 |
-
|
23 |
-
from detectron2.solver import WarmupParamScheduler
|
24 |
-
from detectron2.solver.build import get_default_optimizer_params
|
25 |
-
from detectron2.config import LazyCall as L
|
26 |
-
from detectron2.model_zoo import get_config
|
27 |
-
from detectron2.data.samplers import TrainingSampler, InferenceSampler
|
28 |
-
from detectron2.evaluation import DatasetEvaluator
|
29 |
-
from detectron2.utils import comm
|
30 |
-
|
31 |
-
|
32 |
-
"""
|
33 |
-
Note: Here we put reusable code (models, evaluation, data) together with configs just as a
|
34 |
-
proof-of-concept, to easily demonstrate what's needed to train a ImageNet classifier in detectron2.
|
35 |
-
Writing code in configs offers extreme flexibility but is often not a good engineering practice.
|
36 |
-
In practice, you might want to put code in your project and import them instead.
|
37 |
-
"""
|
38 |
-
|
39 |
-
|
40 |
-
def build_data_loader(dataset, batch_size, num_workers, training=True):
|
41 |
-
return torch.utils.data.DataLoader(
|
42 |
-
dataset,
|
43 |
-
sampler=(TrainingSampler if training else InferenceSampler)(len(dataset)),
|
44 |
-
batch_size=batch_size,
|
45 |
-
num_workers=num_workers,
|
46 |
-
pin_memory=True,
|
47 |
-
)
|
48 |
-
|
49 |
-
|
50 |
-
class ClassificationNet(nn.Module):
|
51 |
-
def __init__(self, model: nn.Module):
|
52 |
-
super().__init__()
|
53 |
-
self.model = model
|
54 |
-
|
55 |
-
@property
|
56 |
-
def device(self):
|
57 |
-
return list(self.model.parameters())[0].device
|
58 |
-
|
59 |
-
def forward(self, inputs):
|
60 |
-
image, label = inputs
|
61 |
-
pred = self.model(image.to(self.device))
|
62 |
-
if self.training:
|
63 |
-
label = label.to(self.device)
|
64 |
-
return F.cross_entropy(pred, label)
|
65 |
-
else:
|
66 |
-
return pred
|
67 |
-
|
68 |
-
|
69 |
-
class ClassificationAcc(DatasetEvaluator):
|
70 |
-
def reset(self):
|
71 |
-
self.corr = self.total = 0
|
72 |
-
|
73 |
-
def process(self, inputs, outputs):
|
74 |
-
image, label = inputs
|
75 |
-
self.corr += (outputs.argmax(dim=1).cpu() == label.cpu()).sum().item()
|
76 |
-
self.total += len(label)
|
77 |
-
|
78 |
-
def evaluate(self):
|
79 |
-
all_corr_total = comm.all_gather([self.corr, self.total])
|
80 |
-
corr = sum(x[0] for x in all_corr_total)
|
81 |
-
total = sum(x[1] for x in all_corr_total)
|
82 |
-
return {"accuracy": corr / total}
|
83 |
-
|
84 |
-
|
85 |
-
# --- End of code that could be in a project and be imported
|
86 |
-
|
87 |
-
|
88 |
-
dataloader = OmegaConf.create()
|
89 |
-
dataloader.train = L(build_data_loader)(
|
90 |
-
dataset=L(torchvision.datasets.ImageNet)(
|
91 |
-
root="/path/to/imagenet",
|
92 |
-
split="train",
|
93 |
-
transform=L(T.Compose)(
|
94 |
-
transforms=[
|
95 |
-
L(T.RandomResizedCrop)(size=224),
|
96 |
-
L(T.RandomHorizontalFlip)(),
|
97 |
-
T.ToTensor(),
|
98 |
-
L(T.Normalize)(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
|
99 |
-
]
|
100 |
-
),
|
101 |
-
),
|
102 |
-
batch_size=256 // 8,
|
103 |
-
num_workers=4,
|
104 |
-
training=True,
|
105 |
-
)
|
106 |
-
|
107 |
-
dataloader.test = L(build_data_loader)(
|
108 |
-
dataset=L(torchvision.datasets.ImageNet)(
|
109 |
-
root="${...train.dataset.root}",
|
110 |
-
split="val",
|
111 |
-
transform=L(T.Compose)(
|
112 |
-
transforms=[
|
113 |
-
L(T.Resize)(size=256),
|
114 |
-
L(T.CenterCrop)(size=224),
|
115 |
-
T.ToTensor(),
|
116 |
-
L(T.Normalize)(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
|
117 |
-
]
|
118 |
-
),
|
119 |
-
),
|
120 |
-
batch_size=256 // 8,
|
121 |
-
num_workers=4,
|
122 |
-
training=False,
|
123 |
-
)
|
124 |
-
|
125 |
-
dataloader.evaluator = L(ClassificationAcc)()
|
126 |
-
|
127 |
-
model = L(ClassificationNet)(
|
128 |
-
model=(ResNet)(block=Bottleneck, layers=[3, 4, 6, 3], zero_init_residual=True)
|
129 |
-
)
|
130 |
-
|
131 |
-
|
132 |
-
optimizer = L(torch.optim.SGD)(
|
133 |
-
params=L(get_default_optimizer_params)(),
|
134 |
-
lr=0.1,
|
135 |
-
momentum=0.9,
|
136 |
-
weight_decay=1e-4,
|
137 |
-
)
|
138 |
-
|
139 |
-
lr_multiplier = L(WarmupParamScheduler)(
|
140 |
-
scheduler=L(MultiStepParamScheduler)(
|
141 |
-
values=[1.0, 0.1, 0.01, 0.001], milestones=[30, 60, 90, 100]
|
142 |
-
),
|
143 |
-
warmup_length=1 / 100,
|
144 |
-
warmup_factor=0.1,
|
145 |
-
)
|
146 |
-
|
147 |
-
|
148 |
-
train = get_config("common/train.py").train
|
149 |
-
train.init_checkpoint = None
|
150 |
-
train.max_iter = 100 * 1281167 // 256
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/ChrisPreston/diff-svc_minato_aqua/modules/hubert/hubert_model.py
DELETED
@@ -1,243 +0,0 @@
|
|
1 |
-
import copy
|
2 |
-
import random
|
3 |
-
from typing import Optional, Tuple
|
4 |
-
|
5 |
-
import librosa
|
6 |
-
import torch
|
7 |
-
import torch.nn as nn
|
8 |
-
import torch.nn.functional as t_func
|
9 |
-
from torch.nn.modules.utils import consume_prefix_in_state_dict_if_present
|
10 |
-
|
11 |
-
|
12 |
-
class Hubert(nn.Module):
|
13 |
-
def __init__(self, num_label_embeddings: int = 100, mask: bool = True):
|
14 |
-
super().__init__()
|
15 |
-
self._mask = mask
|
16 |
-
self.feature_extractor = FeatureExtractor()
|
17 |
-
self.feature_projection = FeatureProjection()
|
18 |
-
self.positional_embedding = PositionalConvEmbedding()
|
19 |
-
self.norm = nn.LayerNorm(768)
|
20 |
-
self.dropout = nn.Dropout(0.1)
|
21 |
-
self.encoder = TransformerEncoder(
|
22 |
-
nn.TransformerEncoderLayer(
|
23 |
-
768, 12, 3072, activation="gelu", batch_first=True
|
24 |
-
),
|
25 |
-
12,
|
26 |
-
)
|
27 |
-
self.proj = nn.Linear(768, 256)
|
28 |
-
|
29 |
-
self.masked_spec_embed = nn.Parameter(torch.FloatTensor(768).uniform_())
|
30 |
-
self.label_embedding = nn.Embedding(num_label_embeddings, 256)
|
31 |
-
|
32 |
-
def mask(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
33 |
-
mask = None
|
34 |
-
if self.training and self._mask:
|
35 |
-
mask = _compute_mask((x.size(0), x.size(1)), 0.8, 10, x.device, 2)
|
36 |
-
x[mask] = self.masked_spec_embed.to(x.dtype)
|
37 |
-
return x, mask
|
38 |
-
|
39 |
-
def encode(
|
40 |
-
self, x: torch.Tensor, layer: Optional[int] = None
|
41 |
-
) -> Tuple[torch.Tensor, torch.Tensor]:
|
42 |
-
x = self.feature_extractor(x)
|
43 |
-
x = self.feature_projection(x.transpose(1, 2))
|
44 |
-
x, mask = self.mask(x)
|
45 |
-
x = x + self.positional_embedding(x)
|
46 |
-
x = self.dropout(self.norm(x))
|
47 |
-
x = self.encoder(x, output_layer=layer)
|
48 |
-
return x, mask
|
49 |
-
|
50 |
-
def logits(self, x: torch.Tensor) -> torch.Tensor:
|
51 |
-
logits = torch.cosine_similarity(
|
52 |
-
x.unsqueeze(2),
|
53 |
-
self.label_embedding.weight.unsqueeze(0).unsqueeze(0),
|
54 |
-
dim=-1,
|
55 |
-
)
|
56 |
-
return logits / 0.1
|
57 |
-
|
58 |
-
def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
59 |
-
x, mask = self.encode(x)
|
60 |
-
x = self.proj(x)
|
61 |
-
logits = self.logits(x)
|
62 |
-
return logits, mask
|
63 |
-
|
64 |
-
|
65 |
-
class HubertSoft(Hubert):
|
66 |
-
def __init__(self):
|
67 |
-
super().__init__()
|
68 |
-
|
69 |
-
# @torch.inference_mode()
|
70 |
-
def units(self, wav: torch.Tensor) -> torch.Tensor:
|
71 |
-
wav = torch.nn.functional.pad(wav, ((400 - 320) // 2, (400 - 320) // 2))
|
72 |
-
x, _ = self.encode(wav)
|
73 |
-
return self.proj(x)
|
74 |
-
|
75 |
-
def forward(self, wav: torch.Tensor):
|
76 |
-
return self.units(wav)
|
77 |
-
|
78 |
-
|
79 |
-
class FeatureExtractor(nn.Module):
|
80 |
-
def __init__(self):
|
81 |
-
super().__init__()
|
82 |
-
self.conv0 = nn.Conv1d(1, 512, 10, 5, bias=False)
|
83 |
-
self.norm0 = nn.GroupNorm(512, 512)
|
84 |
-
self.conv1 = nn.Conv1d(512, 512, 3, 2, bias=False)
|
85 |
-
self.conv2 = nn.Conv1d(512, 512, 3, 2, bias=False)
|
86 |
-
self.conv3 = nn.Conv1d(512, 512, 3, 2, bias=False)
|
87 |
-
self.conv4 = nn.Conv1d(512, 512, 3, 2, bias=False)
|
88 |
-
self.conv5 = nn.Conv1d(512, 512, 2, 2, bias=False)
|
89 |
-
self.conv6 = nn.Conv1d(512, 512, 2, 2, bias=False)
|
90 |
-
|
91 |
-
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
92 |
-
x = t_func.gelu(self.norm0(self.conv0(x)))
|
93 |
-
x = t_func.gelu(self.conv1(x))
|
94 |
-
x = t_func.gelu(self.conv2(x))
|
95 |
-
x = t_func.gelu(self.conv3(x))
|
96 |
-
x = t_func.gelu(self.conv4(x))
|
97 |
-
x = t_func.gelu(self.conv5(x))
|
98 |
-
x = t_func.gelu(self.conv6(x))
|
99 |
-
return x
|
100 |
-
|
101 |
-
|
102 |
-
class FeatureProjection(nn.Module):
|
103 |
-
def __init__(self):
|
104 |
-
super().__init__()
|
105 |
-
self.norm = nn.LayerNorm(512)
|
106 |
-
self.projection = nn.Linear(512, 768)
|
107 |
-
self.dropout = nn.Dropout(0.1)
|
108 |
-
|
109 |
-
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
110 |
-
x = self.norm(x)
|
111 |
-
x = self.projection(x)
|
112 |
-
x = self.dropout(x)
|
113 |
-
return x
|
114 |
-
|
115 |
-
|
116 |
-
class PositionalConvEmbedding(nn.Module):
|
117 |
-
def __init__(self):
|
118 |
-
super().__init__()
|
119 |
-
self.conv = nn.Conv1d(
|
120 |
-
768,
|
121 |
-
768,
|
122 |
-
kernel_size=128,
|
123 |
-
padding=128 // 2,
|
124 |
-
groups=16,
|
125 |
-
)
|
126 |
-
self.conv = nn.utils.weight_norm(self.conv, name="weight", dim=2)
|
127 |
-
|
128 |
-
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
129 |
-
x = self.conv(x.transpose(1, 2))
|
130 |
-
x = t_func.gelu(x[:, :, :-1])
|
131 |
-
return x.transpose(1, 2)
|
132 |
-
|
133 |
-
|
134 |
-
class TransformerEncoder(nn.Module):
|
135 |
-
def __init__(
|
136 |
-
self, encoder_layer: nn.TransformerEncoderLayer, num_layers: int
|
137 |
-
) -> None:
|
138 |
-
super(TransformerEncoder, self).__init__()
|
139 |
-
self.layers = nn.ModuleList(
|
140 |
-
[copy.deepcopy(encoder_layer) for _ in range(num_layers)]
|
141 |
-
)
|
142 |
-
self.num_layers = num_layers
|
143 |
-
|
144 |
-
def forward(
|
145 |
-
self,
|
146 |
-
src: torch.Tensor,
|
147 |
-
mask: torch.Tensor = None,
|
148 |
-
src_key_padding_mask: torch.Tensor = None,
|
149 |
-
output_layer: Optional[int] = None,
|
150 |
-
) -> torch.Tensor:
|
151 |
-
output = src
|
152 |
-
for layer in self.layers[:output_layer]:
|
153 |
-
output = layer(
|
154 |
-
output, src_mask=mask, src_key_padding_mask=src_key_padding_mask
|
155 |
-
)
|
156 |
-
return output
|
157 |
-
|
158 |
-
|
159 |
-
def _compute_mask(
|
160 |
-
shape: Tuple[int, int],
|
161 |
-
mask_prob: float,
|
162 |
-
mask_length: int,
|
163 |
-
device: torch.device,
|
164 |
-
min_masks: int = 0,
|
165 |
-
) -> torch.Tensor:
|
166 |
-
batch_size, sequence_length = shape
|
167 |
-
|
168 |
-
if mask_length < 1:
|
169 |
-
raise ValueError("`mask_length` has to be bigger than 0.")
|
170 |
-
|
171 |
-
if mask_length > sequence_length:
|
172 |
-
raise ValueError(
|
173 |
-
f"`mask_length` has to be smaller than `sequence_length`, but got `mask_length`: {mask_length} and `sequence_length`: {sequence_length}`"
|
174 |
-
)
|
175 |
-
|
176 |
-
# compute number of masked spans in batch
|
177 |
-
num_masked_spans = int(mask_prob * sequence_length / mask_length + random.random())
|
178 |
-
num_masked_spans = max(num_masked_spans, min_masks)
|
179 |
-
|
180 |
-
# make sure num masked indices <= sequence_length
|
181 |
-
if num_masked_spans * mask_length > sequence_length:
|
182 |
-
num_masked_spans = sequence_length // mask_length
|
183 |
-
|
184 |
-
# SpecAugment mask to fill
|
185 |
-
mask = torch.zeros((batch_size, sequence_length), device=device, dtype=torch.bool)
|
186 |
-
|
187 |
-
# uniform distribution to sample from, make sure that offset samples are < sequence_length
|
188 |
-
uniform_dist = torch.ones(
|
189 |
-
(batch_size, sequence_length - (mask_length - 1)), device=device
|
190 |
-
)
|
191 |
-
|
192 |
-
# get random indices to mask
|
193 |
-
mask_indices = torch.multinomial(uniform_dist, num_masked_spans)
|
194 |
-
|
195 |
-
# expand masked indices to masked spans
|
196 |
-
mask_indices = (
|
197 |
-
mask_indices.unsqueeze(dim=-1)
|
198 |
-
.expand((batch_size, num_masked_spans, mask_length))
|
199 |
-
.reshape(batch_size, num_masked_spans * mask_length)
|
200 |
-
)
|
201 |
-
offsets = (
|
202 |
-
torch.arange(mask_length, device=device)[None, None, :]
|
203 |
-
.expand((batch_size, num_masked_spans, mask_length))
|
204 |
-
.reshape(batch_size, num_masked_spans * mask_length)
|
205 |
-
)
|
206 |
-
mask_idxs = mask_indices + offsets
|
207 |
-
|
208 |
-
# scatter indices to mask
|
209 |
-
mask = mask.scatter(1, mask_idxs, True)
|
210 |
-
|
211 |
-
return mask
|
212 |
-
|
213 |
-
|
214 |
-
def hubert_soft(
|
215 |
-
path: str
|
216 |
-
) -> HubertSoft:
|
217 |
-
r"""HuBERT-Soft from `"A Comparison of Discrete and Soft Speech Units for Improved Voice Conversion"`.
|
218 |
-
Args:
|
219 |
-
path (str): path of a pretrained model
|
220 |
-
"""
|
221 |
-
dev = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
222 |
-
hubert = HubertSoft()
|
223 |
-
checkpoint = torch.load(path, map_location="cpu")
|
224 |
-
consume_prefix_in_state_dict_if_present(checkpoint, "module.")
|
225 |
-
hubert.load_state_dict(checkpoint)
|
226 |
-
hubert.eval().to(dev)
|
227 |
-
return hubert
|
228 |
-
|
229 |
-
|
230 |
-
def get_units(hbt_soft, raw_wav_path, dev=torch.device('cuda')):
|
231 |
-
wav, sr = librosa.load(raw_wav_path, sr=None)
|
232 |
-
assert (sr >= 16000)
|
233 |
-
if len(wav.shape) > 1:
|
234 |
-
wav = librosa.to_mono(wav)
|
235 |
-
if sr != 16000:
|
236 |
-
wav16 = librosa.resample(wav, sr, 16000)
|
237 |
-
else:
|
238 |
-
wav16 = wav
|
239 |
-
dev = torch.device("cuda" if (dev == torch.device('cuda') and torch.cuda.is_available()) else "cpu")
|
240 |
-
torch.cuda.is_available() and torch.cuda.empty_cache()
|
241 |
-
with torch.inference_mode():
|
242 |
-
units = hbt_soft.units(torch.FloatTensor(wav16.astype(float)).unsqueeze(0).unsqueeze(0).to(dev))
|
243 |
-
return units
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Cyril666/my_abi/modules/model.py
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
import torch.nn as nn
|
3 |
-
|
4 |
-
from utils import CharsetMapper
|
5 |
-
|
6 |
-
|
7 |
-
_default_tfmer_cfg = dict(d_model=512, nhead=8, d_inner=2048, # 1024
|
8 |
-
dropout=0.1, activation='relu')
|
9 |
-
|
10 |
-
class Model(nn.Module):
|
11 |
-
|
12 |
-
def __init__(self, config):
|
13 |
-
super().__init__()
|
14 |
-
self.max_length = config.dataset_max_length + 1
|
15 |
-
self.charset = CharsetMapper(config.dataset_charset_path, max_length=self.max_length)
|
16 |
-
|
17 |
-
def load(self, source, device=None, strict=True):
|
18 |
-
state = torch.load(source, map_location=device)
|
19 |
-
self.load_state_dict(state['model'], strict=strict)
|
20 |
-
|
21 |
-
def _get_length(self, logit, dim=-1):
|
22 |
-
""" Greed decoder to obtain length from logit"""
|
23 |
-
out = (logit.argmax(dim=-1) == self.charset.null_label)
|
24 |
-
abn = out.any(dim)
|
25 |
-
out = ((out.cumsum(dim) == 1) & out).max(dim)[1]
|
26 |
-
out = out + 1 # additional end token
|
27 |
-
out = torch.where(abn, out, out.new_tensor(logit.shape[1]))
|
28 |
-
return out
|
29 |
-
|
30 |
-
@staticmethod
|
31 |
-
def _get_padding_mask(length, max_length):
|
32 |
-
length = length.unsqueeze(-1)
|
33 |
-
grid = torch.arange(0, max_length, device=length.device).unsqueeze(0)
|
34 |
-
return grid >= length
|
35 |
-
|
36 |
-
@staticmethod
|
37 |
-
def _get_square_subsequent_mask(sz, device, diagonal=0, fw=True):
|
38 |
-
r"""Generate a square mask for the sequence. The masked positions are filled with float('-inf').
|
39 |
-
Unmasked positions are filled with float(0.0).
|
40 |
-
"""
|
41 |
-
mask = (torch.triu(torch.ones(sz, sz, device=device), diagonal=diagonal) == 1)
|
42 |
-
if fw: mask = mask.transpose(0, 1)
|
43 |
-
mask = mask.float().masked_fill(mask == 0, float('-inf')).masked_fill(mask == 1, float(0.0))
|
44 |
-
return mask
|
45 |
-
|
46 |
-
@staticmethod
|
47 |
-
def _get_location_mask(sz, device=None):
|
48 |
-
mask = torch.eye(sz, device=device)
|
49 |
-
mask = mask.float().masked_fill(mask == 1, float('-inf'))
|
50 |
-
return mask
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/ttLib/tables/_c_v_a_r.py
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
from . import DefaultTable
|
2 |
-
from fontTools.misc import sstruct
|
3 |
-
from fontTools.misc.textTools import bytesjoin
|
4 |
-
from fontTools.ttLib.tables.TupleVariation import (
|
5 |
-
compileTupleVariationStore,
|
6 |
-
decompileTupleVariationStore,
|
7 |
-
TupleVariation,
|
8 |
-
)
|
9 |
-
|
10 |
-
|
11 |
-
# https://www.microsoft.com/typography/otspec/cvar.htm
|
12 |
-
# https://www.microsoft.com/typography/otspec/otvarcommonformats.htm
|
13 |
-
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cvar.html
|
14 |
-
|
15 |
-
CVAR_HEADER_FORMAT = """
|
16 |
-
> # big endian
|
17 |
-
majorVersion: H
|
18 |
-
minorVersion: H
|
19 |
-
tupleVariationCount: H
|
20 |
-
offsetToData: H
|
21 |
-
"""
|
22 |
-
|
23 |
-
CVAR_HEADER_SIZE = sstruct.calcsize(CVAR_HEADER_FORMAT)
|
24 |
-
|
25 |
-
|
26 |
-
class table__c_v_a_r(DefaultTable.DefaultTable):
|
27 |
-
dependencies = ["cvt ", "fvar"]
|
28 |
-
|
29 |
-
def __init__(self, tag=None):
|
30 |
-
DefaultTable.DefaultTable.__init__(self, tag)
|
31 |
-
self.majorVersion, self.minorVersion = 1, 0
|
32 |
-
self.variations = []
|
33 |
-
|
34 |
-
def compile(self, ttFont, useSharedPoints=False):
|
35 |
-
tupleVariationCount, tuples, data = compileTupleVariationStore(
|
36 |
-
variations=[v for v in self.variations if v.hasImpact()],
|
37 |
-
pointCount=len(ttFont["cvt "].values),
|
38 |
-
axisTags=[axis.axisTag for axis in ttFont["fvar"].axes],
|
39 |
-
sharedTupleIndices={},
|
40 |
-
useSharedPoints=useSharedPoints,
|
41 |
-
)
|
42 |
-
header = {
|
43 |
-
"majorVersion": self.majorVersion,
|
44 |
-
"minorVersion": self.minorVersion,
|
45 |
-
"tupleVariationCount": tupleVariationCount,
|
46 |
-
"offsetToData": CVAR_HEADER_SIZE + len(tuples),
|
47 |
-
}
|
48 |
-
return b"".join([sstruct.pack(CVAR_HEADER_FORMAT, header), tuples, data])
|
49 |
-
|
50 |
-
def decompile(self, data, ttFont):
|
51 |
-
axisTags = [axis.axisTag for axis in ttFont["fvar"].axes]
|
52 |
-
header = {}
|
53 |
-
sstruct.unpack(CVAR_HEADER_FORMAT, data[0:CVAR_HEADER_SIZE], header)
|
54 |
-
self.majorVersion = header["majorVersion"]
|
55 |
-
self.minorVersion = header["minorVersion"]
|
56 |
-
assert self.majorVersion == 1, self.majorVersion
|
57 |
-
self.variations = decompileTupleVariationStore(
|
58 |
-
tableTag=self.tableTag,
|
59 |
-
axisTags=axisTags,
|
60 |
-
tupleVariationCount=header["tupleVariationCount"],
|
61 |
-
pointCount=len(ttFont["cvt "].values),
|
62 |
-
sharedTuples=None,
|
63 |
-
data=data,
|
64 |
-
pos=CVAR_HEADER_SIZE,
|
65 |
-
dataPos=header["offsetToData"],
|
66 |
-
)
|
67 |
-
|
68 |
-
def fromXML(self, name, attrs, content, ttFont):
|
69 |
-
if name == "version":
|
70 |
-
self.majorVersion = int(attrs.get("major", "1"))
|
71 |
-
self.minorVersion = int(attrs.get("minor", "0"))
|
72 |
-
elif name == "tuple":
|
73 |
-
valueCount = len(ttFont["cvt "].values)
|
74 |
-
var = TupleVariation({}, [None] * valueCount)
|
75 |
-
self.variations.append(var)
|
76 |
-
for tupleElement in content:
|
77 |
-
if isinstance(tupleElement, tuple):
|
78 |
-
tupleName, tupleAttrs, tupleContent = tupleElement
|
79 |
-
var.fromXML(tupleName, tupleAttrs, tupleContent)
|
80 |
-
|
81 |
-
def toXML(self, writer, ttFont):
|
82 |
-
axisTags = [axis.axisTag for axis in ttFont["fvar"].axes]
|
83 |
-
writer.simpletag("version", major=self.majorVersion, minor=self.minorVersion)
|
84 |
-
writer.newline()
|
85 |
-
for var in self.variations:
|
86 |
-
var.toXML(writer, axisTags)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|